This project has moved and is read-only. For the latest updates, please go here.

MaskedTextBox Mask binding

Jun 26, 2012 at 8:01 PM
Edited Jun 26, 2012 at 8:32 PM

Hello! Is it possible to bind Mask somehow? I need to load Mask for MasketTextBox control from config file or DB

Jun 27, 2012 at 6:49 PM



The MaskedTextBox.Mask property is a dependency property.  You should be able to bind to it.

Jun 27, 2012 at 9:13 PM

When I'm doing something like that: Mask="{Binding Path=SomeMask}" - I'm getting error: Mask cannot be null. Parameter name:MaskedTextProvider

Jun 27, 2012 at 9:50 PM

Can you show me the XAML of your application, or at least the XAML of the MaskedTextBox?  What is the DataContext of the MaskedTextBox?  What is the value in the "SomeMask" property?

Jun 27, 2012 at 10:09 PM

Probably it's because I'm using MVVM. Error(System.ArgumentNullException) appears only when view is activated. After that mask is successfully bonded

<wpfx:MaskedTextBox  Name="TestTextBox1" Style="{StaticResource TextInput}" Mask="{Binding Path=TestMask}"/>

 public string TestMask
                return "00"; //will be taken from DB

Jun 28, 2012 at 8:39 AM

FallbackValue in Binding solved my problem. Nebuleux, thank you very much