Hi all, First question here. Anyway, here it goes:
I have a XAML Windows with a lot of DatePicker controls (DatePicker from the WPFToolkit on CodePlex). Every DatePicker has a default Value of 1/1/1990 and if no other date is selected, I want (or rather my boss :-) ) to display the Text in gray italic and not in Black. Thus, it makes it easy to see which fields the Date has not yet been entered.
This might be easy, but I'm quite new to WPF/XAML. In fact, these are my first steps using it.
So here is what I have and which works great actually:
<Style TargetType="{x:Type my:DatePicker}">
<Style.Triggers>
<Trigger Property="Text" Value="1/1/1990">
<Setter Property="Foreground" Value="DarkGray"/>
<Setter Property="ToolTip" Value="Please select a date"/>
<Setter Property="FontStyle" Value="Italic"/>
</Trigger>
</Style.Triggers>
</Style>
Problem is, it doesn't work on every machine because of localization/regional settings issues obviously.
So I tried this:
<Style TargetType="{x:Type my:DatePicker}">
<Style.Triggers>
<Trigger Property="Text" Value="{Binding Source={x:Static p:Settings.Default}, Path=MinDate, Mode=TwoWay}">
<Setter Property="Foreground" Value="DarkGray"/>
<Setter Property="ToolTip" Value="Veuillez choisir une date"/>
<Setter Property="FontStyle" Value="Italic"/>
</Trigger>
</Style.Triggers>
</Style>
Notice the difference in the "Value" property of the trigger. This yields following error:
A 'Binding' cannot be set on the 'Value' property of type 'Trigger'. A 'Binding' can only be set on a DependencyProperty of a DependencyObject.
Which I do understand the meaning of and I understand why this doesn't work. (Note that MinDate is of type DateTime with Value 1/1/1990)
So, how could I achieve the result from my first code snippet on all computers?
Thanks for the time.