datatrigger

ControlTemplate with DataTrigger Vs. DataTemplate with DataTemplateSelector

China☆狼群 提交于 2019-11-28 07:01:37
I have a generic control which displays an editor based on the type property inside a ViewModel. Currently it's implemented using Control , ControlTemplate and DataTrigger like this - <Control x:Name="MainControl" Grid.Column="1" TargetUpdated="OnTargetUpdated"> <Control.Style> <Style> <Style.Triggers> <DataTrigger Binding="{Binding Path=EditorType}" Value="{x:Static view:EditorType.Bool}"> <Setter Property="Control.Template" Value="{StaticResource boolTemplate}" /> </DataTrigger> <DataTrigger Binding="{Binding Path=EditorType}" Value="{x:Static view:EditorType.Text}"> <Setter Property=

wpf datatrigger on an image source

寵の児 提交于 2019-11-27 23:30:13
问题 Assuming the binding is right and the image files are where they shuld be, can anyone spot why the image in the xaml below won't change when the trigger evaluates to true? Cheers, Berryl <Image Source="..\..\Images\OK.png" Grid.Column="2" Stretch="None"> <Image.Style> <Style> <Style.Triggers> <DataTrigger Binding="{Binding TimeSheet, Converter={StaticResource overQuotaConv}}" Value="True"> <Setter Property="Image.Source" Value="..\..\Images\Error.png"/> </DataTrigger> </Style.Triggers> <

DataTrigger not firing

穿精又带淫゛_ 提交于 2019-11-27 22:29:01
I have the following xaml: <DockPanel> <DockPanel> <CheckBox IsChecked="{Binding Path=Test}" /> <CheckBox IsChecked="{Binding Path=Test}" /> </DockPanel> <DockPanel DockPanel.Dock="Left" Width="10" Background="Blue"> <DockPanel.Style> <Style> <Style.Triggers> <DataTrigger Binding="{Binding Path=Test}" Value="True"> <Setter Property="DockPanel.Background" Value="Yellow" /> </DataTrigger> </Style.Triggers> </Style> </DockPanel.Style> </DockPanel> </DockPanel> Now - the 2 checkboxes link properly - checking one will check the other - but the datatrigger is not firing at all. What am I doing wrong

WPF Animation “Cannot freeze this Storyboard timeline tree for use across threads”

眉间皱痕 提交于 2019-11-27 15:27:16
I currently have a listbox that has its selected item bound to a property on my ViewModel. Whenever the selected item isn't null I want to perform an animation on it. However I keep getting the following error "Cannot freeze this Storyboard timeline tree for use across threads" and from research sort of understand why this is happening. However I am unsure of what approach I need to take to get the behavior I want. <Storyboard x:Key="ShowItemEdit"> <DoubleAnimation Storyboard.TargetName="lstItemList" Storyboard.TargetProperty="ListBox.Width" To="{Binding ActualWidth, ElementName=UserControl}"

How to get DataTemplate.DataTrigger to check for greater than or less than?

ε祈祈猫儿з 提交于 2019-11-27 14:33:57
The following DataTemplate.DataTrigger makes the age display red if it is equal to 30. How do I make the age display red if it is greater than 30? <DataTemplate DataType="{x:Type local:Customer}"> <Grid x:Name="MainGrid" Style="{StaticResource customerGridMainStyle}"> <Grid.ColumnDefinitions> <ColumnDefinition Width="100"/> <ColumnDefinition Width="150"/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition/> <RowDefinition/> <RowDefinition/> </Grid.RowDefinitions> <TextBlock Grid.Column="0" Grid.Row="0" Text="First Name" Margin="5"/> <TextBlock Grid.Column="1" Grid.Row="0" Text="

What is the replacement for DataTrigger in Silverlight

点点圈 提交于 2019-11-27 13:37:35
This is my scenario. I have 2 Properties. Type and State. Type is an Enum with 3 values eg, ball, car, arrow. State is an int which would accept 3 state values eg., -1, 0, 1. Also, I have 9 images for each state values. Like, if I select type as ball and value as -1, I want to display a Red color ball. If I select type as arrow and value as 1, I want to display a up arrow. etc., I'm able to do this in WPF. I created 3 DataTemplates with an empty Image. Then, I use DataTrigger to check and update the particular image for the selected StateValue. But, in silverlight how can I do this. I know, I

WPF Style DataTrigger with binding to DataContext not working

若如初见. 提交于 2019-11-27 13:00:39
问题 I have a TextBox with a style that has a DataTrigger which changes the text, like this: <Grid> <TextBlock Text="Foo"> <TextBlock.Style> <Style BasedOn="{StaticResource TextStyle}" TargetType="TextBlock"> <Style.Triggers> <DataTrigger Binding="{Binding MyBool}" Value="True"> <Setter Property="Text" Value="Bar"/> </DataTrigger> </Style.Triggers> </Style> </TextBlock.Style> </TextBlock> </Grid> But it's not working, the text never changes to "Bar". I have tested using another TextBlock with Text

How can I provide multiple conditions for data trigger in WPF?

青春壹個敷衍的年華 提交于 2019-11-27 10:18:29
How can I provide multiple conditions for data trigger in WPF? Use MultiDataTrigger type <Style TargetType="ListBoxItem"> <Style.Triggers> <DataTrigger Binding="{Binding Path=State}" Value="WA"> <Setter Property="Foreground" Value="Red" /> </DataTrigger> <MultiDataTrigger> <MultiDataTrigger.Conditions> <Condition Binding="{Binding Path=Name}" Value="Portland" /> <Condition Binding="{Binding Path=State}" Value="OR" /> </MultiDataTrigger.Conditions> <Setter Property="Background" Value="Cyan" /> </MultiDataTrigger> </Style.Triggers> </Style> serine @jasonk - if you want to have "or" then negate

DataTrigger not firing

杀马特。学长 韩版系。学妹 提交于 2019-11-27 04:34:54
问题 I have the following xaml: <DockPanel> <DockPanel> <CheckBox IsChecked="{Binding Path=Test}" /> <CheckBox IsChecked="{Binding Path=Test}" /> </DockPanel> <DockPanel DockPanel.Dock="Left" Width="10" Background="Blue"> <DockPanel.Style> <Style> <Style.Triggers> <DataTrigger Binding="{Binding Path=Test}" Value="True"> <Setter Property="DockPanel.Background" Value="Yellow" /> </DataTrigger> </Style.Triggers> </Style> </DockPanel.Style> </DockPanel> </DockPanel> Now - the 2 checkboxes link

ControlTemplate with DataTrigger Vs. DataTemplate with DataTemplateSelector

我的未来我决定 提交于 2019-11-27 01:40:19
问题 I have a generic control which displays an editor based on the type property inside a ViewModel. Currently it's implemented using Control , ControlTemplate and DataTrigger like this - <Control x:Name="MainControl" Grid.Column="1" TargetUpdated="OnTargetUpdated"> <Control.Style> <Style> <Style.Triggers> <DataTrigger Binding="{Binding Path=EditorType}" Value="{x:Static view:EditorType.Bool}"> <Setter Property="Control.Template" Value="{StaticResource boolTemplate}" /> </DataTrigger>