The CellDecorationsNeeded event isn't raised for pinned columns/rows
I would expect this event would be raised regardless of pinned state. Otherwise the UI would not be consistent when columns/rows are pinned.
// SomeVirtualGrid.xaml.cs
public SomeVirtualGrid()
{
InitializeComponent();
vg.PinColumnLeft(0);
vg.PinColumnLeft(1);
vg.PinColumnLeft(2);
}
Cell contents are missing when the header size is assigned through the e.Size property of the HeaderSizeEventArgs in the HeaderSizeNeeded event handler of RadVirtualGrid.
This happens only for some of the cells and when the viewport has many rows and columns.
To work this around, instead of setting the header size in the HeaderSizeNeeded event handler, use the ColumnWidth property of RadVirtualGrid.
<telerik:RadVirtualGrid ColumnWidth="50" />
An ArgumentOutOfRangeException is thrown if you try to copy a pinned cell using Ctrl+C while there is a selected cell. This is reproduced by selecting an unpinned cell, then click a pinned cell to set is a current, and then press Ctrl+C to copy the pinned cell.
To work this around, override the RadVirtualGridCommands.Copy command behavior and implement the copy action from scratch.
static MainWindow()
{
CommandManager.RegisterClassCommandBinding(typeof(RadVirtualGrid), new CommandBinding(RadVirtualGridCommands.Copy, OnVirtualGridCopyExecuted, OnVirtualGridCopyCanExecute));
}
private static void OnVirtualGridCopyCanExecute(object sender, CanExecuteRoutedEventArgs e)
{
e.Handled = true;
e.CanExecute = true;
}
private static void OnVirtualGridCopyExecuted(object sender, ExecutedRoutedEventArgs e)
{
var virtualGrid = (RadVirtualGrid)sender;
var strBuilder = new StringBuilder();
// DataView is a custom property in MyDataProvider (deriving from DataProvider) and it just returns this.Source (which is a protected property).
var items = ((MyDataProvider)virtualGrid.DataProvider).DataView;
int pinnedColumnsCount = (int)virtualGrid.Tag;
foreach (VirtualGridCellInfo cell in virtualGrid.SelectedCells)
{
int columnIndex = cell.ColumnIndex + pinnedColumnsCount;
ItemPropertyInfo propertyInfo = virtualGrid.DataProvider.ItemProperties[columnIndex];
var descriptor = (PropertyDescriptor)propertyInfo.Descriptor;
object rowData = items.GetItemAt(cell.RowIndex);
object cellValue = descriptor.GetValue(rowData);
strBuilder.Append(cellValue + " ");
}
Clipboard.SetText(strBuilder.ToString());
}
To work this around, you can disable the default behavior that happens on right click and then implement custom one from scratch. To do so, you can use the PreviewKeyDown event of RadVirtualGrid.
private void VirtualGrid_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
{
var virtualGrid = (RadVirtualGrid)sender;
if (e.Key == System.Windows.Input.Key.Right)
{
var currentCell = virtualGrid.CurrentCellInfo;
var newCellIndex = Math.Min(currentCell.ColumnIndex + 1, virtualGrid.InitialColumnCount - 1);
var nextCell = new VirtualGridCellInfo(currentCell.RowIndex, newCellIndex, vg);
virtualGrid.CurrentCellInfo = nextCell;
virtualGrid.SelectedCells.Clear();
virtualGrid.SelectedCells.Add(nextCell);
var viewportWidth = this.panel.ViewportWidth - virtualGrid.RowHeaderWidth;
var newCellX = (virtualGrid.ColumnWidth * nextCell.ColumnIndex) - this.panel.HorizontalOffset;
if (newCellX >= viewportWidth)
{
var delta = virtualGrid.ColumnWidth + (newCellX - viewportWidth);
this.panel.SetHorizontalOffset(this.panel.HorizontalOffset + delta);
}
e.Handled = true;
}
}
private VirtualGridCompoundPanel panel;
private void VirtualGrid_Loaded(object sender, RoutedEventArgs e)
{
var virtualGrid = (RadVirtualGrid)sender;
this.panel = virtualGrid.FindChildByType<VirtualGridCompoundPanel>();
}
I have an application that uses docking. Each pane contain a virtual grid.
If the user toggles between panes, any future font size changes are not reflected by the virtual grid
I have attached a demo project that shows the problem.
After launching the application:
1) click the Increase/Decrease Font buttons to see the font size change.
2) click tab2 then go back to tab1
3) click the Increase/Decrease Font buttons to see the Virtual Grids font size no longer updates.
(I have a third virtual grid outside of the Docking that shows that the font does change if not used inside of a docking control)