Closed gitjsdr26 closed 2 years ago
@gitjsdr26 sorry for the long delay on this. I am not sure exactly what is being asked here. This library does support validation it appears different than the default MahApps validation because it is designed to confirm to Google's material design specification.
You can see an example in the demo app
@Keboo , Your are welcome and thank you for your reply. I was wondering if it was possible for my purpose to display this kind of MahApps Adorner while using Material Design
Best regards.
Hi @gitjsdr26 if you would prefer to turn off the material design validation template and switch back to the MahApps one, you can do something like this:
<TextBox Validation.ErrorTemplate="{StaticResource MahApps.Templates.ValidationError}">
Thank you @Keboo . I tried this but I get errors Resource not found despite having added
<Source="pack://application:,,,/MahApps.Metro;component/Styles/ValidationErrorTemplate.xaml" />
in my ResourceDictionary
Defining a new style also doesn't work
<Style x:Key="CustomTextBlock" BasedOn="{StaticResource MaterialDesignButtonTextBlock}" TargetType="{x:Type TextBlock}">
<Setter Property="FontSize" Value="16"/>
<Setter Property="FontWeight" Value="Regular"/>
<Setter Property="Validation.ErrorTemplate" Value="{DynamicResource MahApps.Templates.ValidationError}" />
</Style>
Do you have an idea ? Best regards
@gitjsdr26 it looks like you are trying to define the style on TextBlock
(which is readonly), and not on TextBox
Hi @Keboo , You are right. I corrected my application ResourceDictionary like
<!-- TextBox -->
<Style x:Key="CustomTextBox" BasedOn="{StaticResource MaterialDesignTextBox}" TargetType="{x:Type TextBox}">
<Setter Property="Validation.ErrorTemplate" Value="{StaticResource MahApps.Templates.ValidationError}" />
</Style>
then my TextBox
<TextBox Margin="0 0 0 0" Text="{Binding PCInterFrameDelay, NotifyOnTargetUpdated=True, NotifyOnSourceUpdated=True, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" MaxLength="3" Style="{StaticResource CustomTextBox}"/>
But when calling the error template, I get the error
System.InvalidOperationException : ''{DependencyProperty.UnsetValue}' n'est pas une valeur valide pour la propriété 'ErrorTemplate'.'
Sorry for dropping the ball on this one. Based on the error message, it looks like it is failing to resolve the error template.
It's now working. Thank you
Dear All, Is it possible to display TextBox Adorner error like MahApps does ? See https://github.com/MahApps/MahApps.Metro/issues/3320
Thank you Best regards