We have two date controls as From and To and have validation of each date, if validation fails user should stay on the same field. Also we want date control to appear with date mask ( / / ) and dropdown icon.
I was able to do this with following settings and validation code with setting focus (not given here)
<igEditors:XamDateTimeEditor DropDownButtonDisplayMode="Always"
DisplayMode="IncludeBoth" IsAlwaysInEditMode="True"/>
Issues that we are having now as below,
1. We used IsAlwaysInEditMode="True" to make the mask appear to the user without actually start entering the date. But this is causing date value not being notified to view model. This may be because IsAlwaysInEditMode="True" means EditModeStarted and EditModeEnded will be ignored with this setting.
2. We used DropDownButtonDisplayMode="Always" to show the dropdown to the user without actually mouse over on the date control. This is causing user to leave the one date control with the business errored date to the other when user click the dropdown icon of the other date control.
Please guide us in the right direction, Thanks
Tusky said: 1. We used IsAlwaysInEditMode="True" to make the mask appear to the user without actually start entering the date. But this is causing date value not being notified to view model. This may be because IsAlwaysInEditMode="True" means EditModeStarted and EditModeEnded will be ignored with this setting.
Tusky said: 2. We used DropDownButtonDisplayMode="Always" to show the dropdown to the user without actually mouse over on the date control. This is causing user to leave the one date control with the business errored date to the other when user click the dropdown icon of the other date control.
Hi
In additon to what Andrew has said.
If in case you are using EditModeStarted/Ended for updating the view model, then you have two options:
* You can use some other mechanism other than EditModeStarted/Ended events, like focus change (for this you can bind to IsFocusWithin property of the ValueEditor to know when the user leaves the focus), to handle updating of the view model.
* Leave the IsAlwaysInEditMode set to false and instead specify a ValueToDisplayTextConverter that will show the prompt characters when not in edit mode. Here’s the code for ValueToDisplayTextConverter:
public class MyMaskDisplayTextConverter : IValueConverter
{
private static IValueConverter g_baseDisplayTextConverter;
static MyMaskDisplayTextConverter( )
XamMaskedEditor tmpEditor = new XamMaskedEditor( );
g_baseDisplayTextConverter = tmpEditor.ValueToDisplayTextConverterResolved;
}
public object Convert( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture )
object val = g_baseDisplayTextConverter.Convert( value, targetType, parameter, culture );
XamMaskedEditor maskEditor = parameter as XamMaskedEditor;
if ( null != maskEditor )
if ( null == val || val is string && 0 == ( (string)val ).Length )
val = maskEditor.GetText( MaskMode.IncludeBoth );
return val;
public object ConvertBack( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture )
return g_baseDisplayTextConverter.ConvertBack( value, targetType, parameter, culture );
Is this issue resolved ? Do you have any further questions regarding this ?
I am very sorry for the delay. It worked fine when the converter was set, it display the blank and the format before the control gets focus.
Issue now is once date is selected it gets binded to a property in my ViewModel. When I clear the value on clicking a button by setting date property to nothing. The value appears to be on the date, but when i click the control it disappear and again the date appears after lossing the focus.
Now did not had time to debug this issue, I will update after this week end. Thanks
Hello
Have you managed to resolve this issue ? Is there any update ? Thanks.
I have used NullText property, which worked for my scenario
Sorry, It is working correctly. It was my mistake in the coding which was causing issue. This is now resolved for me. Thanks for your help
Now I got a problem with our Dirty Tracking, When the I set the (val = "__/__/____") for date that has empty value, it actally fires the change event once again, which we do not want to happen. We want our change event fire when user manually clear the date, not when window loaded with default date. Any suggestion how to overcome this issue?
Thanks for your help, finally I was able to make it work by changing it to val = "__/__/____". I don't why maskEditor.Text is empty string, but maskEditor.GetText(MaskMode.IncludeBoth) is giving the old value which was set to nothing from the ViewModel.
I am glad your suggestion help, thanks you for your help.
Public Function Convert(ByVal value As Object, ByVal targetType As System.Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements
System.Windows.Data.IValueConverter.Convert
Dim val As Object = g_baseDisplayTextConverter.Convert(value, targetType, parameter, culture)
Dim maskEditor As XamMaskedEditor = TryCast(parameter, XamMaskedEditor)
If maskEditor IsNot Nothing Then
If val Is Nothing OrElse TypeOf val Is String AndAlso 0 = DirectCast(val, String).Length Then
' val = maskEditor.GetText(MaskMode.IncludeBoth)
val =
"__/__/____"
End If
Return val
End Function