I have the following:
<StackPanel Grid.Row="3" Orientation="Horizontal"> <Label Width="80" Content="Phone:"/> <ig:XamMaskedInput Width="100" Text="{Binding PhoneNumber}" Mask="(###) ###-####" InvalidValueBehavior="DisplayErrorMessage"/> </StackPanel>
I would like to know how to set the error message to display.
Thanks.
Hello,
Thank you for your post. I have been looking into your issue and I am not sure why you are trying to validate the input as you have set the ‘Mask’ property of the XamMaskedInput. This way you have already restricted the input and it can accept only the specific characters defined in the Mask. Regarding the question about the ‘InvalidValueBehavior’ I can suggest you look into the following links from our online documentation :
http://help.infragistics.com/doc/windowsui/2013.2/CLR4.5?page=InfragisticsWRT.Controls.Editors.XamMaskedInput.v13.2~Infragistics.Controls.Editors.InvalidValueBehavior.html
http://help.infragistics.com/Help/Doc/WPF/2012.2/CLR4.0/html/InfragisticsWPF4.Editors.v12.2~Infragistics.Windows.Editors.ValueEditor~InvalidValueBehavior.html
The second one is WPF related but it is relevant to the WinUI, too.
Please let me know, if you need any further assistance on this matter.
Hi Yanko,
Thank you for your response.
I am not trying to validate the masked input, what I am trying to do is to inform the user what he/she should put in.
For example, if the mask for a textbox is #####, it only accepts numbers, when the user keys in letters, the textbox will not accept the user's input, but I would like to inform the user that this textbox only accept numbers. I was thinking to display the error message to let the user know.
I am just checking if you require any further assistance on the matter.
Hi,
Thank you for your reply. I have been looking into your scenario and I can suggest you put a hidden Textblock near to the XamMaskedInput and makes it visible when the input is focused by handling the GotFocus and LostFocus events like e.g. :
<Editors:XamMaskedInput x:Name="maskedEditor" Mask="(###) ###-####" Grid.Column="0" Height="25" Width="100" Text="{Binding PhoneNumber}" GotFocus="maskedEditor_GotFocus_1" LostFocus="maskedEditor_LostFocus_1" >
<Editors:XamMaskedInput.ValueConstraint>
<Editors:ValueConstraint MaxLength="10" />
</Editors:XamMaskedInput.ValueConstraint>
</Editors:XamMaskedInput>
<TextBlock Visibility="Collapsed" Width="100" Height="25" Foreground="Red"x:Name="txtBlock" Grid.Column="1">Please use only digits</TextBlock>
private void maskedEditor_GotFocus_1(object sender, RoutedEventArgs e)
{
this.txtBlock.Visibility = Windows.UI.Xaml.Visibility.Visible;
}
private void maskedEditor_LostFocus_1(object sender, RoutedEventArgs e)
this.txtBlock.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
Please let me know, if you need any further assistance on this matter