Tag: xaml

WPF绑定DataGrid中的SelectedItem

所以,我有一个TabControl绑定到一个项目列表(每个选项卡是一个项目) – 这很好。 每个选项卡的内容都是一个DataGrid,其中包含项目员工的列表 – 也可以正常工作。 现在,我想显示一些关于当前在DataGrid上选择的员工的信息。 这是一些代码:MainWindow.xaml文件: 后来,我想通过简单地在标签中编写来测试这个绑定: 和MainWindowViewModel: public Employee SelectedEmployee { get { return selectedEmployee; } set { if (selectedEmployee != value) { selectedEmployee = value; NotifyPropertyChanged(“SelectedEmployee”); } } } public event PropertyChangedEventHandler PropertyChanged; private void NotifyPropertyChanged(String info) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(info)); } } 我是WPF的新手,我已经阅读了一些提示,但他们没有帮助。 标签’emp’没有显示任何内容。 我错过了什么?

如何更改UWP中所选ListView项的突出显示颜色(Windows 10)

我正在使用C#和XAML开发Windows 10应用程序。 我有一个ListView,我想更改所选项目的默认HighLight颜色。 我看到很多代码示例(像这样 ),但都是为WP8或Win8设计的,我试图实现这些,但它们对我不起作用。 一般来说,我很难修改控件的默认主题,因为我找不到有用的文档。 如果有人可以帮助我突出颜色并且还推荐我很好的文档,那将是很棒的。

ListView上的水平滚动

我目前正在页面上捕获PointerMoved事件以使用水平菜单。 因此,用户可以向左/向右滑动,页面将相应地设置动画。 这在用户触摸静态元素(TextBlock等)时有效,但如果它们触摸ListView则会捕获触摸事件。 如何实现ListView,以便当用户垂直滚动时,它正常工作,但当用户水平滚动时,它会将事件传递给我的代码?

使用触发器WPF MVVM更改映像

这可能是一个没有脑子的人,但我似乎无法让它发挥作用。 我有一个视图模型暴露了一个名为bool NotFound的属性我想将它绑定到一个触发器,以便当它更改我的控件上的图像更改时。 这是我用作其中一个视图模型的数据模板的xaml。 我希望能够绑定到NotFound属性并更改图像源。 谢谢。 弥敦道

检测简单触摸手势

任何人都可以解释如何在WinRT应用程序中检测简单的触摸手势? 我尝试使用GestureRecognizer类,但它不起作用: public MainPage() { this.InitializeComponent(); Windows.UI.Input.GestureRecognizer gr = new Windows.UI.Input.GestureRecognizer(); gr.CrossSliding += gr_CrossSliding; gr.Dragging += gr_Dragging; gr.Holding += gr_Holding; gr.ManipulationCompleted += gr_ManipulationCompleted; gr.ManipulationInertiaStarting += gr_ManipulationInertiaStarting; gr.ManipulationStarted += gr_ManipulationStarted; gr.ManipulationUpdated += gr_ManipulationUpdated; gr.RightTapped += gr_RightTapped; gr.Tapped += gr_Tapped; gr.GestureSettings = Windows.UI.Input.GestureSettings.ManipulationRotate | Windows.UI.Input.GestureSettings.ManipulationTranslateX | Windows.UI.Input.GestureSettings.ManipulationTranslateY | Windows.UI.Input.GestureSettings.ManipulationScale | Windows.UI.Input.GestureSettings.ManipulationRotateInertia | Windows.UI.Input.GestureSettings.ManipulationScaleInertia | Windows.UI.Input.GestureSettings.ManipulationTranslateInertia | Windows.UI.Input.GestureSettings.Tap; […]

从c#调用在xaml中声明的故事板

我试图从c#调用在xaml中声明的故事板。 … 我无法访问代码隐藏文件中的“PlayStoryboard”。 我有什么想法吗?

使用Font Awesome更改WPF中的字体图标

我正在使用Font Awesome的图标来渲染C#WPF应用程序中的基本字体图像。 在运行期间,当我尝试更改TextBlock以显示不同的字体图标但显示的是unicode表示而不是字体图标时。 我已经创建了一个示例应用程序来显示它。 单击任一按钮时,它会将TextBlock的Text属性替换为相应图标的unicode。 项目中有一个Resources文件夹,其中FontAwesome.ttf字体文件作为构建资源,TextBlock的FontFamily属性引用该文件。 这是我的示例应用程序的源代码: 代码隐藏: namespace FontAwesomeTest { public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } private void btnGlass_Click(object sender, RoutedEventArgs e) { tblkFontIcon.Text = “”; } private void btnMusic_Click(object sender, RoutedEventArgs e) { tblkFontIcon.Text = “”; } private void btnSearch_Click(object sender, RoutedEventArgs e) { tblkFontIcon.Text = “”; […]

使用http:\\ URL的WPF图像UriSource和数据绑定

我在WPF用户控件中显示带有Web URL的图像时遇到问题。 我已经解决了2008年8月在本网站上提出的类似问题的所有建议( 图像UriSource和数据绑定 ),但这些建议都没有奏效。 我想做的是: ImageFilePathUri是一个从字符串路径创建的Uri: public Uri ImageFilePathUri { get { return new Uri(this.ImageFilePath); } } } 这样就必须设置“Property’UriSource’或属性’StreamSource’。” 错误如预期。 我也尝试过使用值转换器: public class ImageConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { var image = new BitmapImage(); image.BeginInit(); if (value != null) { image.UriSource = new Uri((string)value); } […]

使用附带事件与caliburn micro Message.Attach

我正在尝试使用caliburn micro消息来触发我创建的附加事件: public static class DataChanging { public delegate void DataChangingEventHandler(object sender, DataChangingEventArgs e); public static readonly RoutedEvent ChangingEvent = EventManager.RegisterRoutedEvent(“Changing”, RoutingStrategy.Bubble, typeof(DataChangingEventHandler), typeof(DataChanging)); public static void AddChangingHandler(DependencyObject o, DataChangingEventHandler handler) { ((UIElement)o).AddHandler(DataChanging.ChangingEvent, handler); } public static void RemoveChangingHandler(DependencyObject o, DataChangingEventHandler handler) { ((UIElement)o).RemoveHandler(DataChanging.ChangingEvent, handler); } public static bool GetActivationMode(DependencyObject obj) { return (bool)obj.GetValue(ActivationModeProperty); } […]

如何使用XAML在WPF中列出颜色?

如何获取我可以在Visual Studio Designer中选择的所有颜色的列表(即System.Windows.Media.Colors ,但这不是集合)并使用WPF和XAML标记将它们放入我自己的ComboBox ?