Wpf 动态地使背景颜色变浅
我有一个带包装的堆叠面板 当用户将鼠标悬停在wrappanel上时,我希望背景比当前背景亮一点,这样用户就可以清楚地单击它 背景由我的viewmodel绑定,可以更改 我使用转换器将枚举转换为某种颜色Wpf 动态地使背景颜色变浅,wpf,Wpf,我有一个带包装的堆叠面板 当用户将鼠标悬停在wrappanel上时,我希望背景比当前背景亮一点,这样用户就可以清楚地单击它 背景由我的viewmodel绑定,可以更改 我使用转换器将枚举转换为某种颜色 <StackPanel x:Name="UserCallAlarmPanel" > <StackPanel.Resources> <Style x:Key="AlarmStyle" TargetType="{x:Type WrapPanel}
<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>
Opacity
的有效值介于0(完全透明)和1(完全不透明)之间。如果想要20%的不透明度,则需要使用0.2作为值。不透明度的有效值介于0(完全透明)和1(完全不透明)之间。如果你想要20%的不透明度,你需要使用0.2的值。哦,好的,这确实是个问题。愚蠢的