如何在wpf中将epander标题鼠标悬停和选定颜色更改为trasparent
我是wpf新手,我不知道如何在鼠标上方将标题颜色更改为透明,并在扩展标题中选择如何在wpf中将epander标题鼠标悬停和选定颜色更改为trasparent,wpf,windows,Wpf,Windows,我是wpf新手,我不知道如何在鼠标上方将标题颜色更改为透明,并在扩展标题中选择 <DataTemplate > <StackPanel > <Expander Name="expander1" Background="Transparent" Margin="0,0,0,0" MouseEnter="Expander_MouseEnter" Width="Auto" Expanded="Expander_Expanded" Collapsed="Exp
<DataTemplate >
<StackPanel >
<Expander Name="expander1" Background="Transparent" Margin="0,0,0,0" MouseEnter="Expander_MouseEnter" Width="Auto" Expanded="Expander_Expanded" Collapsed="Expander_Collapsed" PreviewGotKeyboardFocus="Expander_PreviewGotKeyboardFocus" Style="{DynamicResource PlusMinusExpanderStyle}" >
<Expander.Header>
<StackPanel Width="Auto" Height="Auto">
<Grid x:Name="InnerData" Width="Auto" >
<Grid.RowDefinitions>
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"></ColumnDefinition>
<ColumnDefinition Width="35"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Padding="0,18,0,0" Width="Auto" VerticalAlignment="Center" Text="{Binding Path=sHeader}" Foreground="#FF6E809C" Background="Transparent" FontSize="20" FontWeight="SemiBold" TextTrimming="CharacterEllipsis" />
<Image Height="20" Source="/Images/disclosure_collapsed_copy_30.png" Width="Auto" x:Name="img_collapsed" Grid.Row="0" Grid.Column="1" Margin="0,18,0,0"></Image>
<Image Height="20" Source="/Images/disclosure_expanded_copy_30.png" Width="Auto" x:Name="img_expanded" Visibility="Collapsed" Grid.Row="0" Grid.Column="1" Margin="0,18,0,0"></Image>
</Grid>
您需要使用“VisualStateManager”更改标题的颜色。在要更改颜色的控件内使用以下代码
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="Pressed"/>
<VisualState x:Name="MouseOver">
<Storyboard>
<ColorAnimationUsingKeyFrames Storyboard.TargetName="HeaderControlName"
Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)">
<EasingColorKeyFrame KeyTime="0"
Value="Transparent" />
</ColorAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
他为什么需要使用“VisualStateManager”?触发器、事件或其他解决方案如何?他是否从VSM中受益?