datatrigger

WPF: DataTrigger bound to a ContextMenu MenuItem works only once

此生再无相见时 提交于 2020-01-07 00:03:05
问题 I am trying to hide colummns in a Datagrid (bound to a DataTable ) with DataTrigger . So that the user can choose which columns are displayed. My problem is that this only works once. Normaly I would say that I need the INotifyPropertyChanged , however my ContextMenu is defined in XAML so I am not sure if and how to do that. Here my XAML <ContextMenu > .... <MenuItem Header="Apply" x:Name="ButtonApply" /> </ContextMenu> <DataGrid ItemsSource="{Binding Path=TabDataTable}" AutoGenerateColumns=

Why does my MenuItem have an Icon when I have overridden the DataTemplate?

混江龙づ霸主 提交于 2020-01-05 12:34:15
问题 I have successfully implement a WPF menu where the top-level items are drawn as large buttons and the lower level items are drawn as standard menu items (see my previous questions here and here). In my original attempt at this my lower-level item template ( SubItemTemplate in the example below) contained an image and a textblock. The result was something that looked like a normal menu item with an empty Icon area and the image next to the text in the text part of the menu item. I was not

Why does my MenuItem have an Icon when I have overridden the DataTemplate?

让人想犯罪 __ 提交于 2020-01-05 12:34:12
问题 I have successfully implement a WPF menu where the top-level items are drawn as large buttons and the lower level items are drawn as standard menu items (see my previous questions here and here). In my original attempt at this my lower-level item template ( SubItemTemplate in the example below) contained an image and a textblock. The result was something that looked like a normal menu item with an empty Icon area and the image next to the text in the text part of the menu item. I was not

DataTrigger Error

半腔热情 提交于 2020-01-03 05:55:04
问题 I am working with some multi-trriggers as per this posting. The binding and error are below. I am using a custom markup extension to display the resource image so it could be suspect but I don't think so since I have used it in styles before. The error message says I am applying the wrong property for the type and I don't see why yet. Cheers, Berryl triggers <Style x:Key="AvatarPathImageStyle" TargetType="{x:Type Image}"> <Setter Property="Source" Value="{Binding AvatarPath}"/> <Setter

How to set Panel.ZIndex or other attached properties via DataTrigger?

↘锁芯ラ 提交于 2020-01-02 15:26:09
问题 I am trying to have a circular overlay come to the top when a certain view model enters an offline state. So it becomes partially transparent and on top of other elements in the Grid. DataTriggers in the style have worked for everything so far, but I cannot set Panel.ZIndex. There is no error in build or run, but the property is not set (I assume because it's an attached property?) <Ellipse Fill="DarkGray" Panel.ZIndex="-10" Width="50" Height="50"> <Ellipse.Style TargetType="Ellipse"> <Style>

WPF TextBlock Negative Number In Red

我的梦境 提交于 2020-01-02 02:42:08
问题 I am trying to figure out the best way to create a style/trigger to set foreground to Red, when value is < 0. what is the best way to do this? I'm assuming DataTrigger, but how can I check for negative value, do i have to create my own IValueConverter? 回答1: If you are not using an MVVM model (where you may have a ForegroundColor property), then the easiest thing to do is to create a new IValueConverter, binding your background to your value. In MyWindow.xaml: <Window ... xmlns:local="clr

Making a WPF Label (or other element) flash using animation

牧云@^-^@ 提交于 2020-01-02 01:23:07
问题 I have a label that I only make visible based on one of my ViewModel Properties. Here is the XAML: <Label HorizontalAlignment="Center" VerticalAlignment="Center" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontSize="24" Width="200" Height="200" > <Label.Content > Option in the money! </Label.Content> <Label.Style> <Style TargetType="{x:Type Label}"> <Setter Property="Visibility" Value="Hidden" /> <Style.Triggers> <DataTrigger Binding="{Binding OptionInMoney}" Value=

How to datatrigger an animation upon updated ViewModel property?

送分小仙女□ 提交于 2020-01-01 05:48:22
问题 I have the following DataGrid cell, which I would like to animate its background colour briefly as soon as the underlying LastTradePrice property changes its value. <DataGridTextColumn Header="Last Trade Price" Binding="{Binding LastTradePrice}"> <DataGridTextColumn.CellStyle> <Style TargetType="DataGridCell"> <Style.Triggers> // ??? <DataTrigger Binding="{Binding LastTradePrice}" Value="True"> <DataTrigger.EnterActions> <BeginStoryboard> <Storyboard> <ColorAnimation To="Aqua" Duration="0:0:0

How to datatrigger an animation upon updated ViewModel property?

℡╲_俬逩灬. 提交于 2020-01-01 05:48:05
问题 I have the following DataGrid cell, which I would like to animate its background colour briefly as soon as the underlying LastTradePrice property changes its value. <DataGridTextColumn Header="Last Trade Price" Binding="{Binding LastTradePrice}"> <DataGridTextColumn.CellStyle> <Style TargetType="DataGridCell"> <Style.Triggers> // ??? <DataTrigger Binding="{Binding LastTradePrice}" Value="True"> <DataTrigger.EnterActions> <BeginStoryboard> <Storyboard> <ColorAnimation To="Aqua" Duration="0:0:0

Unable to set ContentTemplate via DataTrigger

自古美人都是妖i 提交于 2020-01-01 05:18:10
问题 I want the ContentTemplate to vary according to the value in the DataTrigger . And yes, I considered using a DataTemplateSelector , but now I need a DataTrigger or better said a MultiDataTrigger . Please take a look at the following sample app, the DataTemplate doesn't change: <Window x:Class="Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:src="clr-namespace:WpfApplication1"> <StackPanel> <CheckBox