Reputation: 78
I'm creating a wpf application, which holds a text box. When the text box is disabled (the default state) I'm binding it to something, but when the user double click the text box it's changing its state to enabled and the user can edit it. But when I type something after the text box is enabled, it's deleted every second because of the trigger (maybe the ui is updating and the trigger with him). When I did using code and just cleared the binding after double click it worked fine. But I don't want to do it through code, I know that I'm just missing a little thing for the XAML to work.
This is my current XAML:
<Style.Triggers>
<Trigger Property="TextBox.IsEnabled" Value="False">
<Setter Property="Text" Value="{Binding some binding}"/>
</Trigger>
<Trigger Property="TextBox.IsEnabled" Value="True">
<Setter Property="Text" Value="{x:Null}"/>
</Trigger>
</Style.Triggers>
Thanks!
Upvotes: 1
Views: 1386
Reputation: 50672
Would it help to set the Binding but change its direction to OneWayToSource?
<Style.Triggers>
<Trigger Property="TextBox.IsEnabled" Value="False">
<Setter Property="Text" Value="{Binding someBinding}"/>
</Trigger>
<Trigger Property="TextBox.IsEnabled" Value="True">
<Setter Property="Text" Value="{Binding Path=someBinding, Mode=OneWayToSource}"/>
</Trigger>
</Style.Triggers>
Upvotes: 2