Reputation: 193
I'm trying to set up a TextEdit box in my WPF project, but I have some problems with my mask.
XAML:
<dxe:TextEdit x:Name="dxTextEdit"
Height="23" MinWidth="200" Width="Auto"
HorizontalAlignment="Right"
Text="{Binding Value, Mode=TwoWay}"
MaskType="RegEx"
MaxLength="{Binding InputLength}"
Mask="{Binding Mask, Mode=TwoWay}"
/>
Where Mask returns a string like "[a-zA-Z0-9]" and InputLength returns a value. I cannot insert anything in the box or I can insert one character at best. The thing is, the mask works just fine in my SpinEdit box, which is coded like this:
XAML:
<dxe:SpinEdit x:Name="dxSpinEdit"
Height="23" MinWidth="200" Width="Auto"
HorizontalAlignment="Right"
Text="{Binding Value, Mode=TwoWay}"
MaskType="Numeric"
IsFloatValue="{Binding FloatValue}"
MinValue="{Binding MinValue}"
MaxValue="{Binding MaxValue}"
Mask="{Binding Mask, Mode=TwoWay}"
MaxLength="{Binding Path=InputLength}"
MaskShowPlaceHolders="{Binding ShowPlaceHolder}"
InvalidValueBehavior="WaitForValidValue"
MaskUseAsDisplayFormat="True"
AllowRoundOutOfRangeValue="True"
/>
Where Mask returns strings like "d", "n0"
I need to be able to bind input length and a sting that defines my mask inside xaml. Any ideas what I'm doing wrong? I went through most of the devexpress forums and I found something like this: Mask="([a-zA-Z0-9]|\s){0,31}" but it doesn't allow me to modify the length or the regex.
Upvotes: 0
Views: 1216
Reputation: 17848
In masked mode, the TextEdit.MaxLength property is not operational and must be set to 0. In this instance, the number of characters an end-user can enter is specified by the editor's mask. Take a look at Quantifiers section of Mask Type: Extended Regular Expressions help article to learn how to create an appropriate mask:
[a-zA-Z0-9]{0,_} // you should replace _ with the exact length value
Upvotes: 1