I have faced a problem with the WPF styles.
In the root userControl I am having the resource defined like this:
<UserControl.Resources>
<Style TargetType="{x:Type MyControl}">
<Setter Property="MyControl.AAA" Value="Value1" />
</Style>
</UserControl.Resources>
This works just fine, it affects all the MyControl elements in the whole visual tree hierarchy.
If I attempt to change the setter using the DataTrigger, like this:
<UserControl.Resources>
<Style TargetType="{x:Type MyControl}">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=SelectedAAAValue}" Value="Value1">
<Setter Property="MyControl.AAA" Value="Value1" />
</DataTrigger>
<DataTrigger Binding="{Binding Path=SelectedAAAValue}" Value="Value2">
<Setter Property="MyControl.AAA" Value="Value2"/>
</DataTrigger>
</Style.Triggers>
</Style>
</UserControl.Resources>
The style is applied only to the root element of a specific MyControl type.
Can anybody explain me why it is happening and how can I apply the style to all specific elements via DataTriggers?
Many thanks for any help. Ondra