When setting the VirtualItemCount on refreshing the data source, the scrollbar jumps to the top. If the VirtualItemCount is initially set, the behavior is not reproduced. The workaround is to use the scrolling mechanism of the control and scroll back to the desired item.
Currently, the following workaround can be applied: private void RadGridView_Loaded(object sender, RoutedEventArgs e) { var gridView = sender as RadGridView; foreach (var column in gridView.Columns) { if (!column.IsResizable) { Dispatcher.BeginInvoke((Action) (() => { var radGridView = column.Parent; foreach (var header in radGridView.ChildrenOfType<GridViewHeaderCell>()) { if (header.Column.DisplayIndex == column.DisplayIndex) { var leftGripper = header.ChildrenOfType<Thumb>().Where(x => x.Name == "PART_LeftHeaderGripper").First(); { leftGripper.Visibility = Visibility.Collapsed; } } else if (header.Column.DisplayIndex == (column.DisplayIndex - 1)) { var rightGripper = header.ChildrenOfType<Thumb>().Where(x => x.Name == "PART_RightHeaderGripper").First(); { rightGripper.Visibility = Visibility.Collapsed; } } } }), DispatcherPriority.Render); } } }
This is reproducible in a hierarchical scenario. The nested gridview loses its selection when its parent row is scrolled out of the viewport.
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; } }
To work this around you can set the EnableColumnGroupsVirtualization to False. Alternatively you can change the FrozenColumnCount before adding the columns, and reset it once the process is done. For example: gridTriffDetails.FrozenColumnCount = 0; gridTriffDetails.Columns.Add(newColumn); gridTriffDetails.Columns.Add(newColumn1); gridTriffDetails.Columns.Add(newColumn2); gridTriffDetails.FrozenColumnCount = 1;
workaround is to override the OnInitialized of the custom column: protected override void OnInitialized(EventArgs e) {/* //if XAML assemblies Theme theme = StyleManager.GetTheme(this); Type themeType = null; if (theme != null) { themeType = theme.GetType(); } this.DefaultStyleKey = new ThemeResourceKey() { ElementType = typeof(Telerik.Windows.Controls.GridViewColumn), ThemeType = themeType };*/ }
As a temporary workaround, the following custom keyboard command provider can be used: public class CustomKeyboardCommandProvider : DefaultKeyboardCommandProvider { private GridViewDataControl parentGrid; public CustomKeyboardCommandProvider(GridViewDataControl grid) : base(grid) { this.parentGrid = grid; } public override IEnumerable<ICommand> ProvideCommandsForKey(Key key) { List<ICommand> commandsToExecute = base.ProvideCommandsForKey(key).ToList(); if (key == Key.Enter) { commandsToExecute.Clear(); commandsToExecute.Add(RadGridViewCommands.CommitEdit); commandsToExecute.Add(RadGridViewCommands.BeginEdit); commandsToExecute.Add(RadGridViewCommands.MoveDown); } return commandsToExecute; } }
A possible workaround is to predefine the CellTemplate of the column as well.