How can i validate them with combination Like PropertyNumber and OwnerNumber combination should not exist in database. Right now i am using IDataErrorInfo but it only validates one value at a time.
<Label DockPanel.Dock="Top" Width="Auto" Height="16"/>
<TextBox Name="PropertyNumber" DockPanel.Dock="Top" Text="{Binding
UpdateSourceTrigger=PropertyChanged, Mode=TwoWay, Path=SelectedPropertyNumber,
ValidatesOnDataErrors=True}" Width="115" Height="22"
HorizontalAlignment="Left" IsEnabled="{Binding
PropertyNumbersEnabled,UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}" />
<Label DockPanel.Dock="Top" Width="Auto" Height="16"/>
<TextBox Name="OwnerNumber" Text="{Binding BindingGroupName=NGLDataFormGrp,
Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True,
Path=OwnerNumber}" DockPanel.Dock="Top" HorizontalAlignment="Left"
Width="115" Height="22" IsEnabled="{Binding
UpdateSourceTrigger=PropertyChanged,
Path=OwnerNumberEnabled, Mode=TwoWay}"/>
I’m not sure if this is the best solution but it works for me. The way I usually handle this is create a DataTrigger binded to a boolean property which indicates valid or invalid.
If the boolean is false, I style the border red. If not, no border color.
Here’s an example DataTrigger:
If you apply this style to both of our textboxes bound to the same boolean, they’ll both appear with a glow red border when the boolean is false.