Show Error Message in Textbox
See original GitHub issueI have a Textbox that I just want user’s input is numeric, I use Validation Rule then I custom ErrorTemplate but I can’t show any message in Template. This is my Textbox:
<TextBox Margin="100,20,100,0"
x:Name="txbSDT"
FontSize="14"
FontFamily="/CoffeeHome;component/CoffeeHomeFont/#Roboto"
materialDesign:HintAssist.Hint="Số điện thoại"
Style="{StaticResource MaterialDesignFloatingHintTextBox}"
Validation.ErrorTemplate="{StaticResource textBoxErrorTemplate}">
<TextBox.Text>
<Binding Path="Staff.Sdt" UpdateSourceTrigger="PropertyChanged">
<Binding.ValidationRules>
<validation:NumericValidation PropertyName="Số điện thoại"
ValidatesOnTargetUpdated="True"/>
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
And this is my ErrorTemplate:
<ControlTemplate x:Key="textBoxErrorTemplate">
<StackPanel>
<Border BorderBrush="Red" BorderThickness="1">
<AdornedElementPlaceholder Name="a" />
</Border>
<TextBlock Foreground="Red" Text="{Binding [0].ErrorContent}"/>
</StackPanel>
</ControlTemplate>
In the preview of Visual Studio I can still see the message but when I build and test the message doesn’t show. I can’t understand, is it because of the default of Material Design ? If someone can help me out, I will very grateful
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (4 by maintainers)
@supernhok13 Excellent. I assume this issue can be closed now?
Closed due to inactivity