wpf - Change DatePicker style based on SelectedDate -


The first question here. Anyway, it goes here:

I have an XAML Windows with many DatePicker controls (CodePlex on WPFToolkit with DatePicker). Each date picture is the default value of 1/1/1990 and if no second date is selected, then 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 have not been entered yet.

It may be easy, but I am quite new to WPF / XAML. Actually, this is my first step using it

So what I have here and what really works great is:

type = "{ X: type my: date picture} "& gt; & Lt; Style.Triggers & gt; & Lt; Trigger Property = "Text" Value = "1/1/1990" & gt; & Lt; Setter Property = "Foreground" Value = "DarkGrey" /> & Lt; Setter property = "tooltip" value = "please select a date" /> & Lt; Setter property = "fonttail" value = "italic" /> & Lt; / Catalyst & gt; & Lt; /Style.Triggers> & Lt; / Style & gt;

The problem is that due to localization / regional setting issues this does not work on every machine.

So I tried to do this:

  & gt; Style target type = "{x: type my: date picture}" & gt; & Lt; Style.Triggers & gt; & Lt; Trigger property = "text" value = "{binding source = {x: static p: settings. Default}, path = minadata, mode = double}" & gt; & Lt; Setter Property = "Foreground" Value = "DarkGrey" /> & Lt; Setter property = "tooltip" value = "Weevils Chillies a date" /> & lt; Setter property = "fonttail" value = "italic" /> & Lt; / Catalyst & gt; & Lt; /Style.Triggers> & Lt; / Style & gt;  

See the difference in the trigger's "value" property This yield is the following error:

A 'binding' property of 'value' type 'trigger' Can not be set to A 'binding' can only be set dependent on the dependency object.

What I think and I understand why this does not work (Note that the date of the Mindada type is 1/1 9/190)

< P> So, how do I get results from my first code snippet on all computers?

Time.

Ok, for those people who run in the same problem, here it is that I finally What's done in:

In XAM:

  & lt; Src: ConvertManet X: Key = "Convert Manate" /> & Lt; Style TargetType = "{x: Type my: DatePicker}" & gt; & Lt; Style.Triggers & gt; & Lt; DataTrigger Binding = "{Binding Path = Selected Date, Relative Soros = {Relative Asher}}, Converter = {Static Resource Convertamentum}}" Value = "True" & gt; & Lt; Setter Property = "Foreground" Value = "DarkGrey" /> & Lt; Setter Property = "Tooltip" Value = "Choose a Date" /> & Lt; Setter property = "fonttail" value = "italic" /> & Lt; / DataTrigger & gt; & Lt; /Style.Triggers> & Lt; / Style & gt; In CodeBHind:  
  Public class convertManadat: iValueConverter {public object convert (object value, type type, object parameter, system globalization.Culture Info culture) {if (value == null) {back true; } And {datetime date = profession. Properties Settings. Default.mandet; If (value is the date time) {date = (date time) value; Date of return == profession. Properties Settings. Default.method; } And {return true; }}} Public Object Convertback (type object type, type target type, object parameter, system globalization. Culture info culture) {new non imulated expansions ();  

MinDate has been set up in the settings section of my project until January 1, 1990.

So now, if the selected date is either zero or equal, the converted returns are correct, thus the data triggers are triggered and the style changes if DatePickerTextBox

Is WPF just not good enough? : -)


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -