问题
In my WPF application I use the following xaml: ...
<TextBox
services:TextBoxService.IsFocused="{Binding Path=IsSelected, Mode=OneWay}"
FocusVisualStyle="{x:Null}">
<MultiBinding
Converter="{StaticResource mconv_operableToString}"
UpdateSourceTrigger="PropertyChanged">
<Binding
Path="Value"
Mode="TwoWay"
NotifyOnValidationError="True" />
<Binding
RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type UserControl}}"
Path="DataContext.Status"
Mode="OneWay" />
</MultiBinding>
The view model class which the first binding uses implements IDataErrorInfo for validation purposes. The problem is that although the error is caught in the property setter, the UI doesn't notice it. I have a style defined with an error template which should be applied when any error occurs in the text box. I suppose that maybe this scenario is not allowed with multi binding because where I use single binding everything works fine.
Thanks in advance.
回答1:
It seems to me that nobody knows the answer to this but I suppose that this scenario just doesn't work. I'll try to answer it in case somebody will need it. I've tried to bind my View to my View Model class which implements IDataErrorInfo, in xaml I specified a converter and although everything worked fine, the Errors just didn't show up on the UI. So, I removed the converter from the binding and implemented that logic inside the View Model and, voila now everything works fine.
来源:https://stackoverflow.com/questions/3052150/problem-with-validation-and-multibinding