I am using XamDateTimeEditor and found a strang problem with it. When i databind the TextProperty to a property(of type nullable of DateTimie) the control only accepts the US format (for dates) but when i databind the ValueProperty all works fine (accepts UK formats).it doesn't accept the UK format for the previous case.
can some one please explain to me is it a bug or what i am doing is wrong? i am quite new to WPF.
Kind Regards
Devinder Singh
The FrameworkElement.Language property (defined in microsoft's framework) defaults the Language to en-US. I cannot say why they did not default it to the current culture of the application but that is not something that is under our control. If you were to put a TextBox on the Window and bind to your DateTime property you would get the same behavior because it is the wpf framework that uses the Language property to determine the Culture that it provides to the binding.
I think the defalut Culture should be the one being used by the Application (en-GB in my case since i have no set it up and expect all the controls to use it)?
The Text property is of type string so the wpf framework is going to convert that datetime to a string. The wpf framework uses the FrameworkElement.Language property to determine the culture of the bindings and that defaults to en-US so that's probably why you are seeing this issue. You can try setting the Language property to the culture you are using. You can take a look at this blog post on one way to handle this.
The Value property doesn't have this issue because the Value property is of type object and as such the wpf framework isn't converting your value to a string so the editor gets the datetime as a DateTime?.