I got a grid with a label, a button and a Textbox in it. I want to set the label forground to red & the button property "IsEnabled" To False if the value of the label.Content = "Invalid". However I am not able to set the setter to the targetname in this datatrigger because "Targetame property cannot be set on a Style Setter." How can I fix this so I can use setters for multiple elements with just 1 trigger, I know I can go and put a exact the same datatrigger in the Button.Styletriggers but perhaps there is a better way to do tihs?
<Button Content="Save" Click="btnsave_Click" Grid.Column="1" Grid.Row="2" x:Name="btnsave" IsEnabled="True" />
<Label Content="{Binding ElementName=txtclc, Path=Text, Converter={StaticResource convertcode}}" Name="lblcheckclc" Grid.Row="1" Grid.Column="2">
<Label.Resources>
<Style TargetType="{x:Type Label}">
<Setter Property="Foreground" Value="Green" />
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=lblcheckclc, Path=Content}" Value="Invalid">
<Setter Property="Foreground" Value="Red" />
<Setter TargetName="btnsave" Property="IsEnabled" Value="False" /> <!--This line is the problem-->
</DataTrigger>
</Style.Triggers>
</Style>
</Label.Resources>
</Label>
PS: If I comment the 2nd setter then it works, (if the value of the label = "Invalid" then the forground becomes red