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
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(" ","");
Thanks, does the trick and will do fine for me. Would be nice if there was a property on the control SaveWithFormat or something like that.
You could try setting the DataMode to Raw so literals like spaces are not included in the Value/Text.
Thanks, that's what I'm looking for.