Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problem with validation and multibinding

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.

like image 688
Zoliqa Avatar asked Jul 20 '26 18:07

Zoliqa


1 Answers

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.

like image 164
Zoliqa Avatar answered Jul 23 '26 22:07

Zoliqa



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!