を変更する制御を認識しなかったメニュースタイルです:WPFのトリガーは、私がここにHamburgerMenuを開発しようとしているそのプロパティ
<Style TargetType="local:HamburgerMenu">
<Style.Resources>
<!-- Fill Brushes -->
<SolidColorBrush x:Key="DarkBrush" Color="#40000000" />
</Style.Resources>
<Setter Property="Width" Value="50"/>
<Setter Property="Visibility" Value="Visible"/>
<Setter Property="IsOpen" Value="False"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="local:HamburgerMenu">
<Grid x:Name="mainGrid" Background="{TemplateBinding Background}">
<ToggleButton x:Name="menuIcon" HorizontalAlignment="Left" VerticalAlignment="Top" Height="40" Width="50" IsChecked="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:HamburgerMenu}}, Path=IsOpen}">
<Path x:Name="path" HorizontalAlignment="Center" VerticalAlignment="Center" Stretch="Uniform" Width="30" Fill="{TemplateBinding MenuIconColor}" Data="M2,15.5L22,15.5 22,17.5 2,17.5 2,15.5z M2,10.5L22,10.5 22,12.5 2,12.5 2,10.5z M2,5.5L22,5.5 22,7.5 2,7.5 2,5.5z"/>
</ToggleButton>
<ListBox ItemsSource="{TemplateBinding Content}" HorizontalAlignment="Left" Margin="0,40,0,0" VerticalAlignment="Top" ScrollViewer.HorizontalScrollBarVisibility="Disabled" SelectedIndex="0"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsOpen" Value="True">
<Trigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Storyboard.TargetProperty="Width"
To="300"
Duration="0:0:0.3" AccelerationRatio="0.1" DecelerationRatio="0.9"/>
</Storyboard>
</BeginStoryboard>
</Trigger.EnterActions>
<Trigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Storyboard.TargetProperty="Width"
To="50"
Duration="0:0:0.2"/>
</Storyboard>
</BeginStoryboard>
</Trigger.ExitActions>
</Trigger>
</Style.Triggers>
</Style>
今、私の質問は、私はこのコードが動作しないトグルボタン にマウスオーバーをトリガすることができる方法であるbecuase TargetName = "パス"は認識されません! :
<ToggleButton.Triggers >
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="path" Property="Fill" Value="{StaticResource DarkBrush}" />
</Trigger>
</ToggleButton.Triggers>
、この溶液作品ではなく、完全にマウスがメニューのどこにでもオーバーのときToogleButtonの色が変化しますので、それは、メニューのマウスオーバーだけでなくToogleButtonを誘発するので:
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="path" Property="Fill" Value="{StaticResource DarkBrush}" />
</Trigger>
</ControlTemplate.Triggers>
あなたはこれを試すか、何が起こったのか? – mm8