I'm trying to adapt the example IEditorStrategy for use with a DateTime value.
On my first pass through, I was able to use the default WPF DatePickerTextBox primitive. It seems to work, as a blank value in the text box gets highlighted as invalid.
If I replace the WPF primitive with Xceed.Wpf.Toolkit.DateTimePicker, then I don't get the correct control. It's still a text box.
public class DateTextBoxEditorStrategy : IEditorStrategy
{
public object CreateEditor(FieldContext context)
{
var isDate = context.PropertyDescriptor.PropertyType == typeof(DateTime);
if (!isDate)
{
return null;
}
var picker = new Xceed.Wpf.Toolkit.DateTimePicker();
picker.Format = DateTimeFormat.ShortDate;
BindingOperations.SetBinding(picker, TextBox.TextProperty, context.Binding);
return picker;
}
}
Is this the correct way to go about this? Or is there a better way of handling dates?