Hey there,
long time since i asked a question. I want to display all validation-errors and disable two buttons addicted from the validation-error.
Background:
I have a table where the user can add and delete rows. The primerykey (Number)
shall be validated and if there is an error the add or remove button have to be disabled.
1: Error -> Key-Exsists -> Disable add button; enable remove button
2: Error -> Key is used in other table -> disable remove button
So it's possible that both errors appear at the same time. Therefor i need some help.
I use the ValidationList of Rohit Dot net:
WPF - Multiple Validation on Single Control[
^]
My error-template looks like:
<ControlTemplate
x:Key="validationErrorTemplate">
<DockPanel>
<StackPanel
Orientation="Horizontal"
DockPanel.Dock="Top">
<Grid
Width="12"
Height="12">
<Ellipse
Width="12"
Height="12"
Fill="Red"
HorizontalAlignment="Center"
VerticalAlignment="Center"/>
<TextBlock
Foreground="White"
FontWeight="Heavy"
FontSize="8"
HorizontalAlignment="Center"
VerticalAlignment="Center"
TextAlignment="Center"
ToolTip="{Binding Path=ErrorContent}" />
</Grid>
<TextBlock
Text="{Binding
Path=ErrorContent,
UpdateSourceTrigger=PropertyChanged,
ValidatesOnDataErrors=True,
ValidatesOnExceptions=True}"
FontSize="12"
Foreground="Red"
Margin="5 0 0 0"/>
</StackPanel>
<AdornedElementPlaceholder
x:Name="ErrorAdorner" />
</DockPanel>
</ControlTemplate>
I want something like a converter which has the validationerrors as input and return them gathered as string. Additional i need some mechanism to disable the both buttons. Momentary i use Button-Styles for that:
<Style
x:Key="PopUpAddButtonStyle"
BasedOn="{StaticResource {x:Type Button}}"
TargetType="{x:Type Button}">
<Setter Property="IsEnabled" Value="False" />
<Style.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding ElementName=TextBoxA, Path=(Validation.HasError)}" Value="false"/>
<Condition Binding="{Binding ElementName=TextBoxB, Path=(Validation.HasError)}" Value="false" />
<Condition Binding="{Binding ElementName=TextBoxC, Path=(Validation.HasError)}" Value="false" />
<Condition Binding="{Binding ElementName=TextBoxD, Path=(Validation.HasError)}" Value="false" />
<Condition Binding="{Binding ElementName=TextBoxE, Path=(Validation.HasError)}" Value="false" />
</MultiDataTrigger.Conditions>
<Setter Property="IsEnabled" Value="True" />
</MultiDataTrigger>
</Style.Triggers>
</Style>
Thanks for any help.
Greetings 3DC#