1
votes

I wanted to include part of the bindings of a textbox in a style setter to make the xaml more clearly.

    <Style TargetType="TextBox">
          <Setter Property="Text" Value="{Binding Path=tmp, ValidatesOnDataErrors=True, NotifyOnValidationError=True, UpdateSourceTrigger=PropertyChanged}"/>
    </Style>

Note: I am Binding Path to nothing, it is only needed to avoid an exception. The important bindings are ValidatesOnDataErrors, NotifyOnValidationError and UpdateSourceTrigger. So later I do this

<TextBox Text="{Binding Path=clientLastname}"/>

After this Binding the Bindings ValidatesOnDataErrors, NotifyOnValidationError and UpdateSourceTrigger are back to the default value.

Is there a possibility to only change the Path Binding?

2

2 Answers

0
votes

You could create a binding programmatically with the Binding Class and then change the path.

0
votes

The ValidatesOnDataErrors, NotifyOnValidationError and UpdateSourceTrigger should not be in the Style setter since it sets options for the actual property in your viewmodel which will be bound and in this case this is probably for the clientLastname property.

You should put them where you going to use the text box, so you should add them in the <TextBox Text="{Binding Path=clientLastname}"/>