Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
550
XamMaskedEditor mask format for display and edit only
posted

I have a XamMaskedEditor that I use to format the display of a stock number, e.g. "00 00 0 000 000".  I want the user to see all numbers formated this way and when they type it in they should also use it as a mask.  problem is I don't want to save the spaces back into the database, the number should be saved as "00000000000".

Is this possible and if so how?

Thanks

Parents
  • 2320
    posted

     If the masked editor doesn't do that then the simplest way is most likely to use a converter on your binding.

     

     In your resources:

    <local:StripSpacesConverter x:Key="conv"/>

     

    Elsewhere in XAML: 

    <igEditors:XamMaskedEditor Text="{Binding Path=stockNo, Converter={StaticResource conv}}"/>

     

     In code behind:

     

    public class StripSpacesConverter : IValueConverter

        {

            public object Convert(object value, Type targetType, object parameter, CultureInfo culture)

            {

                 return value;

            }

     

            public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)

            {

                return value.ToString().Replace(" ","");

            }

        }

Reply Children