【发布时间】:2012-05-10 16:41:26
【问题描述】:
我在 wpf 中有 Grid。当我在矩形上做鼠标悬停时,我可以看到颜色变化。但是当我将鼠标悬停在内容上时,我会看到矩形的原始颜色。
我应该写什么来在 ContentPresenter 上应用相同的鼠标悬停效果,或者有什么方法可以在内容演示器的鼠标悬停时更改矩形背景颜色。
<Grid Background="{TemplateBinding Background}" x:Name="dgColumnHeader">
<Border x:Name="border" BorderBrush="Black" BorderThickness="0,0,1,1" Grid.ColumnSpan="1">
<Rectangle Width="116" Margin="3,3,3,3" HorizontalAlignment="Center" RadiusX="7" RadiusY="7">
<Rectangle.Style>
<Style TargetType="{x:Type Rectangle}">
<Setter Property="Fill" Value="{DynamicResource ContentOutofFocusBrush}"></Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Fill" Value="{DynamicResource ActiveItemBrush}" />
</Trigger>
</Style.Triggers>
</Style>
</Rectangle.Style>
</Rectangle>
</Border>
<ContentPresenter x:Name="content" HorizontalAlignment="Center" VerticalAlignment="Center" Content="{TemplateBinding Content}" />
</Grid>
谢谢 深
【问题讨论】: