I have button and custom template for it. In the template I have two buttons inside a grid. Each button has own custom template. Also I have a trigger IsMouseOver for this root grid. My goal is change style for both buttons when mouse is over. But TargetName attribute of Setter does not have access to nested controltemplate's controls.
<Button Style="{StaticResource DropDownStyle}" Content="Downloads"/>
<Style x:Key="DropDownStyle" TargetType="{x:Type Button}">
...
<ControlTemplate TargetType="{x:Type Button}">
<Grid x:Name="DropDownButtonPanel">
...
<Button Grid.Column="0" Content="{TemplateBinding Content}">
<Button.Template>
<ControlTemplate TargetType="Button">
<Grid x:Name="BlackSection"/>
...
<Button Grid.Column="1" Click="OnButtonClick">
<Button.Template>
<ControlTemplate TargetType="Button">
<Grid x:Name="GreenSection"/>
...
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True" SourceName="DropDownButtonPanel">
...
</Trigger>
...
How can I access elements from BlackSection and GreenSection in the ControlTemplate.Triggers. Just setter TargetName = "Name" is not useful.
PS. I use two buttons inside one to handle different Click events. Another solution will be a Click event for Grid element, but I also do not know how to do this.
Thanks in advance for any help!