This project has moved and is read-only. For the latest updates, please go here.

Only Show Filter Icon on MouseOver when applying a dgx:DataGridFilterColumn.Template

Jul 24, 2013 at 8:33 PM
How can I have it so that the filter icon / toggle button is only visible when the mouse is over the column itself?

If subsequently a filter is applied, then the filter icon / toggle button should be visible until it is cleared, (like you remove the background on the togglebutton if the Filter is null).

I'm following your sample with FilterWithPopupControl.
Jul 27, 2013 at 6:37 PM
Do you mean like this:
<Control x:Name="control" x:Class="DataGridExtensionsSample.FilterWithPopupControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:dgx="clr-namespace:DataGridExtensions;assembly=DataGridExtensions">
  <Control.Template>
    <ControlTemplate>
      <Grid>
        <ToggleButton x:Name="button">
          <ToggleButton.Style>
            <Style TargetType="Control">
              <Style.Triggers>
                <DataTrigger Binding="{Binding Path=Filter, ElementName=control}" Value="{x:Null}">
                  <Setter Property="Visibility" Value="Hidden"/>
                </DataTrigger>
                <DataTrigger Binding="{Binding Path=IsMouseOver, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGridColumnHeader}}" Value="True">
                  <Setter Property="Visibility" Value="Visible"/>
                </DataTrigger>
              </Style.Triggers>
            </Style>
          </ToggleButton.Style>

...
Jul 29, 2013 at 9:56 PM
Exactly like that! Thanks very much.

One more thing I am having trouble with is trying to change the color of the filter icon when there is a filter applied. I've tried setting the foreground color in the FilterWithPopupControl's ToggleButton.Style, but nothing seems to change the color of the icon!?

In your sample, you override the filter icon in the data grid resources... but how can I change it within the FilterWithPopupControl itself using the same binding to the Filter property?
Aug 6, 2013 at 11:28 AM
Please check out the latest version, the filter icon color is now configurable, and the samples are adapted.
Aug 7, 2013 at 6:27 PM
Thank you very much for the update!