以下のスタイルでControlTemplate.Triggersを作成しようとしていますが、名前付きのEllipseプロパティとPathプロパティを見つける方法がわかりません。
たとえば、IsMouseOverの場合、楕円の背景を変更します。このスタイルを設定した方法でFillプロパティを設定できるように、楕円を見つける良い方法は何ですか?それをレイアウトするためのより良い方法はありますか?
乾杯、
ベリール
<Style x:Key="CloseCrossToggleButtonStyle" TargetType="{x:Type ToggleButton}">
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<Grid Background="Transparent">
<!-- The background of the button, as an ellipse. -->
<Ellipse x:Name="theEllipse" />
<!-- A path that renders a cross. -->
<Path x:Name="theCross"...
</Grid>
</DataTemplate>
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<ContentPresenter x:Name="theContent"/>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Ellipse.Fill" Value="{StaticResource HoverBackgroundBrush}" />
<Setter Property="Path.Stroke" Value="{StaticResource HoverForegroundBrush}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
わかりました、働いています
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Grid Background="Transparent">
<!-- The background of the button, as an ellipse. -->
<Ellipse x:Name="theEllipse" />
<!-- A path that renders a cross. -->
<Path x:Name="theCross"
...
</Path>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="theEllipse" Property="Fill" Value="{StaticResource HoverBackgroundBrush}" />
<Setter TargetName="theCross" Property="Stroke" Value="{StaticResource HoverForegroundBrush}"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Visibility" Value="Collapsed"/>
</Trigger>
<Trigger Property="IsPressed" Value="true">
<Setter TargetName="theEllipse" Property="Fill" Value="{StaticResource PressedBackgroundBrush}" />
<Setter TargetName="theEllipse" Property="Stroke" Value="{StaticResource PressedBorderBrush}" />
<Setter TargetName="theCross" Property="Stroke" Value="{StaticResource PressedForegroundBrush}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>