Hello,
We currently utilize the XamDateTimeEditor and it works great so far, except we have a rather odd requirement. The requirement is that when the screen is in what we call search mode, then the user can enter in whatever they want into our controls. For example, the user could enter in ">02/01/2009" into the date field to search for records that have a date greater than 02/01/2009. I had hoped that I could simply change the ValueType at runtime via a converter from DateTime to string (depending on screen mode), but this does not resolve the issue because the control will still try to internally set the DateValue to a DateTime via the SyncValuePropertiesOverride method.
Does anyone have any suggestions or workarounds to get this control to behave how we would like it? So far, it looks like my only option is to write our own control.
Thanks in advanced,
-Mike
Hello Mike,
I believe you can change change the Mask property of the XamDateTimerEditor and it will no longer require a DateTime formatting. For example, you can set it to numeric or alphanumeric mask for input, something like this:
private void searchMode_Click(object sender, RoutedEventArgs e)
{
if (searchMode.IsChecked.Value)
xamDateTimeEditor1.Mask = "########";
}
else
xamDateTimeEditor1.ClearValue(XamDateTimeEditor.MaskProperty);
Note that # is a digit placeholder and & is a char placeholder. Moreover, you can see all of the supported masks here : http://help.infragistics.com/Help/NetAdvantage/WPF/2009.2/CLR3.5/html/xamEditors_Masks.html
Thanks for the response. That seems to work for the most part, however, if you look at the output window you will see a TON of System.FormatExceptions, which is something I would rather not have in a shipped product.
Mike,
I might be wrong, but I think you cannot get rid of these exceptions. Basically, the XamDateTimeEditor will expect a date time.
Even with the default settings, if you start typing inside the XamDateTimeEditor you will not have a correct date time right away (except if you paste the value). For example typing 12/__/____ will also throw an exception in the output. You would have to paste 12/12/2002 in order not to get any exceptions. These exceptions are "swallowed" and should not have negative effect on the final result.
However, if you would like to avoid them, then you would have to use a text editor (XamTextEditor or XamMaskedEditor) or switch between XamDateTimeEditor and XamMaskedEditor.