Unplanned
Last Updated: 02 Oct 2026 15:11 by Martin Ivanov

In RadGridView, column header cells and their filter buttons are not exposed to UI Automation (UIA) clients.

Workaround: Subclass DataCellsPresenter, override OnCreateAutomationPeer() to return a custom peer that walks the visual tree for GridViewHeaderCell children and exposes their real peers. This subclass must be wired in via a retemplated GridViewHeaderRow (swap the DataCellsPresenter template part).

public class FixedDataCellsPresenterAutomationPeer : FrameworkElementAutomationPeer
{
    public FixedDataCellsPresenterAutomationPeer(FixedDataCellsPresenter owner)
        : base(owner)
    {
    }

    protected override List<AutomationPeer> GetChildrenCore()
    {
        var children = new List<AutomationPeer>();
        CollectHeaderCellPeers(this.Owner, children);
        return children;
    }

    protected override AutomationControlType GetAutomationControlTypeCore()
    {
        return AutomationControlType.Header;
    }

    private static void CollectHeaderCellPeers(DependencyObject parent, List<AutomationPeer> result)
    {
        int count = VisualTreeHelper.GetChildrenCount(parent);
        for (int i = 0; i < count; i++)
        {
            var child = VisualTreeHelper.GetChild(parent, i);
            if (child is GridViewHeaderCell headerCell)
            {
                var peer = UIElementAutomationPeer.CreatePeerForElement(headerCell);
                if (peer != null)
                {
                    result.Add(peer);
                }
            }
            else
            {
                CollectHeaderCellPeers(child, result);
            }
        }
    }
}

 

  public class FixedDataCellsPresenter : DataCellsPresenter
  {
      protected override AutomationPeer OnCreateAutomationPeer()
      {
          return new FixedDataCellsPresenterAutomationPeer(this);
      }
}

 

<Window.Resources>
    <ControlTemplate x:Key="FixedGridViewHeaderRowTemplate" TargetType="grid:GridViewHeaderRow">
          <!-- other elements -->
            <local:FixedDataCellsPresenter x:Name="PART_DataCellsPresenter"
                                           AutomationProperties.Name="Header Cells Presenter"
                                           Grid.Row="1"
                                           Grid.Column="3" />
           <!-- other elements -->
    </ControlTemplate>
    <Style TargetType="grid:GridViewHeaderRow">
        <Setter Property="Template" Value="{StaticResource FixedGridViewHeaderRowTemplate}" />
    </Style>
</Window.Resources>