Home Forums WPF controls Xceed DataGrid for WPF Binding Mask property

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #26499 |

    Hi everyone,

    I’m trying to use MaskedTextBox outside from a Datagrid and to bind its Mask property:

    <xcdg:MaskedTextBox x:Name=”msk” Value=”10″ ValueDataType=”{x:Type sys:Single}” Height=”20″ Mask=”{Binding Converter={StaticResource MyConvDeTest}}”/>

    My converter is like this:

    public class MyConvDeTest : IValueConverter
    {
    public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
    Person supplier = value as Person;
    if (supplier == null) return null;

    string symbol = string.Empty;
    if (supplier.Symbol != null)
    symbol = ” ” + supplier.Symbol;
    return “#.# ” + symbol;
    }

    So this idea is to provide a dynamic mask to my MaskedTextBox depending of the object binded.

    But it always launch an exception: The mask cannot be applied to the current text. (in MaskCoerceValueCallback.

    So how can I bind the mask to my object?

    Imported from legacy forums. Posted by Richard (had 2416 views)

    Xceed Support
    Member
    Post count: 5658

    The issue itself isn’t with your binding or your converter.

    If you try setting #.# as the mask directly, you would get the exact same exception.

    The representation of the value (10.0) cannot be applied to your mask as there’s only one space for one character before your decimal separator.

    The Xceed’s MaskedTextBox, just like Microsoft’s MaskedTextBox does not allow for variable length masking.

    Imported from legacy forums. Posted by Jenny [Xceed] (had 377 views)

    User (Old forums)
    Member
    Post count: 23064

    So this means that I can’t modify Mask dynamicly?

    Imported from legacy forums. Posted by Richard (had 3947 views)

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.