-1

我有 wpf Expander 控件,当我将鼠标悬停在上面时,我想更改 Header 的背景颜色。这是我的控制:

<Expander Margin="0" ExpandDirection="Right">
    <Expander.Header>
        <StackPanel Orientation="Horizontal" VerticalAlignment="Top">
            <Image Source="placeholder_imageObject.png"  Stretch="Uniform" Margin="6,0,0,0" Width="36" Height="36" VerticalAlignment="Center"/>
            <ContentPresenter Content="Image" VerticalAlignment="Center" Margin="5,0,0,0"/>
            <Path Data="{StaticResource RightArrowGeometry}" Fill="Black"  Margin="14,0,0,0" VerticalAlignment="Center">
            </Path>
        </StackPanel>
    </Expander.Header>
    <Grid Margin="10,0,0,0" Background="White">
        <controls:SymbolController x:Name="dgSymbolControl">
        </controls:SymbolController>
    </Grid>
</Expander>

请帮助感谢赛

4

1 回答 1

1

你可以在你的“Expander.Header”中给你的 StackPanel 一个带有触发器的样式,如下所示:

 <Style x:Key="MyCustomStackPanelStyle" TargetType="{x:Type StackPanel}">
      <Style.Triggers>
        <Trigger Property="IsMouseOver" Value="True">
          <Setter Property="Background" Value="Red" />
        </Trigger>
        <Trigger Property="IsMouseOver" Value="False">
          <Setter Property="Background" Value="Transparent" />
        </Trigger>
      </Style.Triggers>
    </Style>
于 2012-06-30T05:52:13.780 回答