WPF数据网格鼠标悬停关闭按钮

WPF数据网格鼠标悬停关闭按钮,wpf,button,datagrid,mouseover,Wpf,Button,Datagrid,Mouseover,当我将鼠标移到datagrid的列标题上时,它的关闭按钮应该会随着标题弹出以删除列 我有下面的XAML来捕获鼠标越过标题 <Style TargetType="{x:Type DataGridColumnHeader}"> <Setter Property="HorizontalContentAlignment" Value="Center" /> <Setter Property="Height" Value="26" /> <

当我将鼠标移到datagrid的列标题上时,它的关闭按钮应该会随着标题弹出以删除列

我有下面的XAML来捕获鼠标越过标题

<Style TargetType="{x:Type DataGridColumnHeader}">
    <Setter Property="HorizontalContentAlignment" Value="Center" />
    <Setter Property="Height" Value="26" />
    <Style.Triggers>
        <Trigger Property="IsMouseOver" Value="True">
            <Setter Property="Background" Value="{DynamicResource ActiveItemButtonPressedBrush}" />
             ?????????? what should I write here to create that button ??????????
        </Trigger>
    </Style.Triggers>
</Style>

由于我是WPF新手,请帮助我生成XAML。

您需要将DataGrid列的HeaderTemplate作为

<DataTemplate>
    <Button>
       <Button.Style>
          <Style TargetType="{x:Type Button}">
              <Setter Property="Template">
                   <Setter.Value>
                       <ControlTemplate TargetType="{x:Type Button}">
                          ... do you contents here
                          ..text block as visible
                          <Button x:Name="btn"..round button as collapsed

                       <ControlTemplate.Triggers>
                          <Trigger Property="Button.IsMouseOver" Value="True">
                               <Setter Property="Background" Value="{DynamicResource ActiveItemButtonPressedBrush}" />
                               <Setter TargetName="btn" Property="Visibility" Value="Visible"/>


    </Trigger>

              </Setter>