Hi,
I'm trying to handle the Enter KeyDown event myself instead of having the cell in the next row get selected. I'd also like to remove the Tab key function too.
Following this does that but causes more problems:
https://www.syncfusion.com/kb/3815/how-to-change-the-enter-key-behavior-in-sfdatagrid
Is it seems to override my cell selection mode and forces it to full row selection instead of individual cell selection. I can't figure out how to change it back. It's ignoring my XAML and code behind.
It also causes System.NullReferenceException: 'Object reference not set to an instance of an object.' if I double click on any cell.
Removing the selection controller override fixes those issues but I can't use the enter key obviously.
my XAML:
<syncfusion:SfDataGrid x:Name="dGrid" Grid.Column="1" Grid.Row="2"
BorderBrush="Transparent"
Background="Transparent"
AutoGenerateColumns="True"
AllowDeleting="False"
AllowDraggingColumns="False"
AllowEditing="False"
AllowResizingColumns="False"
AllowSorting="False"
IsReadOnly="True"
SelectionMode="Extended"
SelectionUnit="Cell"
ColumnSizer="SizeToCells"
ShowRowHeader="{Binding ShowAxisYHeader}"
HeaderRowHeight="{Binding AxisXHeaderHeight}"
RowHeaderWidth="{Binding RowHeaderWidth}"
RowHeight="{Binding RowHeight}"
AllowRowHoverHighlighting="False"
ItemsSource="{Binding TableDataView}"
ItemsSourceChanged="dGrid_ItemsSourceChanged"
KeyDown="dGrid_KeyDown"
KeyboardNavigation.AcceptsReturn="False"
>
</syncfusion:SfDataGrid>
|
this.dGrid.SelectionController = new GridSelectionControllerExt(dGrid);
public class GridSelectionControllerExt : GridCellSelectionController
{
public GridSelectionControllerExt(SfDataGrid datagrid)
: base(datagrid)
{
}
//overriding the ProcessKeyDown Event from GridSelectionController base class
protected override void ProcessKeyDown(KeyEventArgs args)
{
//here customize based on your scenario
if (args.Key == Key.Enter)
return;
base.ProcessKeyDown(args);
}
} |
Wonderful. That fixed it. Thankyou!