datatrigger

comparing two dynamic values in DataTrigger

送分小仙女□ 提交于 2019-11-26 22:03:19
问题 I want to compare two dynamic values User_id and user_id for equality and setting one property Cursor . Also, when the cursor is hand, I have to execute one function. How to do it? This is the code that I am using: <DataTrigger Binding="{Binding Path=User_id}" Value="{Binding Path=user_id}"> <Setter Property="Cursor" Value="Hand"/> </DataTrigger> 回答1: There are a couple options to attack this. #1. Multibinding Converter You can use Multibinding to input the two values into a

DataTrigger does not change Text property

强颜欢笑 提交于 2019-11-26 21:04:08
I'm attempting to use a data-trigger on a style to change a property. In compliance with the " Minimal, Complete and Verifiable Example " requirements... To reproduce, first create a WPF application in Visual Studio. Within the App.xaml.cs : using System.ComponentModel; using System.Windows; namespace Foo{ /// <summary> /// Interaction logic for App.xaml /// </summary> public partial class App : Application, INotifyPropertyChanged { private bool _clicked; public bool Clicked { get { return this._clicked; } set { this._clicked = value; this.PropertyChanged?.Invoke( this, new

DataTrigger where value is NOT null?

匆匆过客 提交于 2019-11-26 19:27:59
I know that I can make a setter that checks to see if a value is NULL and do something. Example: <TextBlock> <TextBlock.Style> <Style> <Style.Triggers> <DataTrigger Binding="{Binding SomeField}" Value="{x:Null}"> <Setter Property="TextBlock.Text" Value="It's NULL Baby!" /> </DataTrigger> </Style.Triggers> </Style> </TextBlock.Style> </TextBlock> But how can I check for a "not" value... as in "NOT NULL", or "NOT = 3"? Is that possible in XAML? Results: Thanks for your answers... I knew I could do a value converter (which means I would have to go in code, and that would not be pure XAML as I

What is the replacement for DataTrigger in Silverlight

做~自己de王妃 提交于 2019-11-26 18:18:29
问题 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

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

送分小仙女□ 提交于 2019-11-26 16:48:39
问题 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

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

早过忘川 提交于 2019-11-26 14:44:21
问题 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=

DataTrigger does not change Text property

拥有回忆 提交于 2019-11-26 07:49:52
问题 I\'m attempting to use a data-trigger on a style to change a property. In compliance with the \"Minimal, Complete and Verifiable Example\" requirements... To reproduce, first create a WPF application in Visual Studio. Within the App.xaml.cs : using System.ComponentModel; using System.Windows; namespace Foo{ /// <summary> /// Interaction logic for App.xaml /// </summary> public partial class App : Application, INotifyPropertyChanged { private bool _clicked; public bool Clicked { get { return

DataTrigger where value is NOT null?

。_饼干妹妹 提交于 2019-11-26 06:58:19
问题 I know that I can make a setter that checks to see if a value is NULL and do something. Example: <TextBlock> <TextBlock.Style> <Style> <Style.Triggers> <DataTrigger Binding=\"{Binding SomeField}\" Value=\"{x:Null}\"> <Setter Property=\"TextBlock.Text\" Value=\"It\'s NULL Baby!\" /> </DataTrigger> </Style.Triggers> </Style> </TextBlock.Style> </TextBlock> But how can I check for a \"not\" value... as in \"NOT NULL\", or \"NOT = 3\"? Is that possible in XAML? Results: Thanks for your answers...