我有一个带有包装面板的堆栈面板。
当用户将鼠标悬停在包装面板上时,我希望背景比当前背景浅一点,因此用户很清楚他可以单击它。
背景由我的视图模型绑定并且可以更改。
我使用转换器将枚举转换为某种颜色。
<StackPanel x:Name="UserCallAlarmPanel" >
<StackPanel.Resources>
<Style x:Key="AlarmStyle" TargetType="{x:Type WrapPanel}">
<Setter Property="Background" Value="Transparent"/>
<Style.Triggers>
<DataTrigger Binding="{Binding IsMouseOver, ElementName=AlarmPanel}" Value="True" >
<Setter Property="Background" Value="{Binding CallStatus, Converter={StaticResource CallStatusBackgroundConverter}}"/>
<Setter Property="Opacity" Value="20"/>
</DataTrigger>
</Style.Triggers>
</Style>
</StackPanel.Resources>
<WrapPanel Name="AlarmPanel" Height="25" MouseLeftButtonDown="AlarmPanel_MouseLeftButtonDown" Style="{StaticResource AlarmStyle}">
<Viewbox>
<ContentControl Content="{DynamicResource alarm_icon}"/>
</Viewbox
</WrapPanel>
</StackPanel>
我试图更改为不透明度,但这不起作用。