Given we have content control
and its content bound to viewmodel
and viewmodel implements INotifyDataErrorInfo
and property Name can't be set to "X"
when viewmodel.Name set to "X"
then input bound to Name get red border
but contentcontrol get red order too!
Solution:
Set ValidatesOnNotifyDataErrors to False in ContentControl Content binding
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Window x:Class="TestWindow" | |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |
Title="TestWindow" Height="300" Width="300"> | |
<Window.Resources> | |
<DataTemplate DataType="{x:Type TestViewModel}"> | |
<Grid> | |
<TestView /> | |
</Grid> | |
</DataTemplate> | |
</Window.Resources> | |
<ContentPresenter Content="{Binding CurrentViewModel, ValidatesOnNotifyDataErrors=False}"/> | |
</Window> |
No comments:
Post a Comment