「x」の色と楕円の色の両方でマウスの上の色を変更する、中央の「x」を持つ楕円形のボタンが必要です。以下、この 楕円のテキストコンテンツとマウスオーバーカラー
と同様に
は私が
<Grid>
<Grid.Resources>
<Style x:Key="CloseButtonBackgroundStyle" TargetType="{x:Type Ellipse}">
<Setter Property="Width" Value="25" />
<Setter Property="Height" Value="25" />
<Setter Property="Fill" Value="#f4f4f4" />
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Fill" Value="Red" />
</Trigger>
</Style.Triggers>
</Style>
<Style x:Key="CloseButtonForegroundStyle" TargetType="{x:Type TextBlock}">
<Setter Property="Foreground" Value="#898989" />
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="FontSize" Value="16" />
<Setter Property="Padding" Value="0 0 0 4" />
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Foreground" Value="#f9ebeb" />
</Trigger>
</Style.Triggers>
</Style>
</Grid.Resources>
<Ellipse Style="{StaticResource CloseButtonBackgroundStyle}" />
<TextBlock Text="x"
Style="{StaticResource CloseButtonForegroundStyle}"/>
</Grid>
トラブルがIsMouseOverプロパティを使用していたいの標準的な外観を取得します。それは動作しますが、各コントロールに対してのみ機能します。すなわち、私が楕円の上にいるときに、背景が赤く変わりますが、テキストブロックを越えると、楕円はもはやマウスの上になくなり、標準的な塗りつぶしの色に戻ります。
楕円の内容がテキストブロックになるように私のアプローチを変更する必要がありますか?
感謝
優れている、それはまさに私が探していたものです。ありがとう。 – obaylis
それはすべてうまくいってうれしい! –