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>
When GridViewClipboardPasteMode is set to AllSelectedCells and a single clipboard value is pasted into more than one selected cell, RadGridView updates the cell values but does not re-evaluate live grouping for the edited items - rows remain under their previous group header until an explicit Rebind()/refresh.
Pasting into a single cell at a time re-groups correctly.
To work this around, call the CommitEdit and EditItem methods of RadGridView for each row data item in which data was pasted. You can do that in the Pasted event handler:
private void RadGridView_Pasted(object sender, RadRoutedEventArgs e)
{
var editableView = (IEditableCollectionView)this.gridView.Items;
var affectedItems = this.gridView.SelectedCells.Select(c => c.Item).Distinct().ToList();
foreach (var item in affectedItems)
{
editableView.EditItem(item);
editableView.CommitEdit();
}
}
workaround:
public MainWindow()
{
InitializeComponent();
this.grid.Loaded += grid_Loaded;
}
void grid_Loaded(object sender, RoutedEventArgs e)
{
this.grid.ChildrenOfType<Grid>().FirstOrDefault(x => x.Name == "PART_OuterGrid").RowDefinitions[1].Height = GridLength.Auto;
var cells = this.grid.ChildrenOfType<GridViewHeaderCell>();
foreach (GridViewHeaderCell cell in cells)
{
cell.ChildrenOfType<Grid>().FirstOrDefault(x => x.Name == "PART_OuterGrid").RowDefinitions[1].Height = GridLength.Auto;
}
}
The bug happens when we have two or more rows merged in the first column and programmatically, we make the rowDetails for the first row visible, the merged cells of the first column stay merged and are over of the rowDetails, hiding a part of the Row Details:
Hi Team,
We have a large-scale WPF application that uses the Telerik WPF RadGridView across multiple screens. We are experiencing significant memory growth issues. Upon deep analysis of the memory dump, we observed that the RadGridView continuously pushes DispatcherPriority items into the Dispatcher queue. We also noticed an internal timer within the RadGridView that appears to be active even after the control is no longer visible. We would like to understand how to completely detach and stop this internal timer once the control is removed from the screen, and why the RadGridView keeps pushing DispatcherItem entries into the Dispatcher queue.
Telerik Version : 2017.2.503.45
Bind a grid to a DataView
Start editing and change the values of a few cells.
Press Escape twice to cancel the edit of the entire row.
Expected: the values return to the old values
Actual: the values remain the last entered ones