<StackPanel>
<TextBox Text="" x:Name="input"/>
<Button Content="DataTrigger Before">
<Button.Style>
<Style TargetType="Button">
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=input, Path=Text}" Value="1">
<Setter Property="Content" Value="Changed"></Setter>
</DataTrigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
</StackPanel>
Style DataTrigger Setter in Button Content is invalid
Thanks
Your DataTrigger is not change the value of the Content
property because you set it inside the Button declaration. So, once setted, it will never changed. To allow changing, you have to set the value inside the Style.
This will works (I've tried):
<StackPanel>
<TextBox Name="input"/>
<Button>
<Button.Style>
<Style TargetType="Button">
<Setter Property="Content" Value="DataTrigger Before"></Setter>
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=input, Path=Text}" Value="1">
<Setter Property="Content" Value="Changed"></Setter>
</DataTrigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
</StackPanel>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With