Hi,
I want to allow multi-select on my XamDataGrid which has following properties:
<igDP:XamDataGrid Name="xdgBudget" RecordContainerGenerationMode="Virtualize" CellContainerGenerationMode="PreLoad" Loaded="xdgBudget_Loaded" RecordActivated="xdgBudget_RecordActivated" RecordDeactivating="xdgBudget_RecordDeactivating" PreviewKeyDown="xdgBudget_PreviewKeyDown" SelectedItemsChanged="xdgBudget_SelectedItemsChanged" GroupByAreaLocation="None" CellUpdated="xdgBudget_CellUpdated" RecordsInViewChanged="xdgBudget_RecordsInViewChanged" EditModeStarting="xdgBudget_EditModeStarting" x:Uid="38C" Grid.ColumnSpan="4">
and following field settings:
<igDP:XamDataGrid.FieldSettings x:Uid="38U"> <uc:RMFieldSettings LabelClickAction="SelectField" CellClickAction="SelectCell" LabelTextAlignment="Center" AllowEdit="True" SummaryDisplayArea="BottomFixed" SummaryUIType="MultiSelect" x:Uid="38V" /> </igDP:XamDataGrid.FieldSettings> <igDP:XamDataGrid.FieldLayoutSettings x:Uid="38W"> <igDP:FieldLayoutSettings AllowFieldMoving="No" HighlightAlternateRecords="True" AutoGenerateFields="False" RecordSelectorLocation="None" AllowAddNew="False" MaxSelectedRecords="0" SelectionTypeCell="Extended" x:Uid="38X" /> </igDP:XamDataGrid.FieldLayoutSettings>
When I try to Shift+Click in order to achieve multi-selection, only the cell which was clicked is selected and if I try to use arrows with Shift key, the cell is entered in 'EditMode'.
I am new WPF and have no idea how to achieve this. Please help asap.
Thanks in advance!
Regards,
Priya
Hello Priya,
Thank you for your post. I have been looking into it and I created a sample project for you following your scenario and everything seems to work ok on my side. If the sample doesn’t satisfies all your needs feel free to modify it, so it reproduces your behavior and send it back to me for further investigation.
Looking forward for your reply.
Hey Stefan,
First of all thank you for prompt reply.
The problem with my solution is as soon as I hit 'Shift' key or any other key, cell goes into edit mode. i.e xamDatagRid_EditModeStarting event gets fired & therefore I can't use Shift+Click for multi-select.
Is there any way to fix this?
Hello Stefan,
I found what was wrong with my code and fixed it.
It is working as expected now for shift+click but not working for Shift+Arrow(s).
Can you help me with that?
It is working fine now. I had to make following changes in my xamDataGrid_PreviewKeyDown evet to make it work:
if (sender is XamDataGrid && (e.KeyboardDevice.IsKeyDown(Key.LeftShift) || e.KeyboardDevice.IsKeyDown(Key.RightShift)) && (e.KeyboardDevice.IsKeyDown(Key.Down) || e.KeyboardDevice.IsKeyDown(Key.Up) || e.KeyboardDevice.IsKeyDown(Key.Left) || e.KeyboardDevice.IsKeyDown(Key.Right))) { XamDataGrid xdg = (XamDataGrid)sender; Cell c = xdg.ActiveCell; if (c != null) { xdg.BringCellIntoView(c); xdg.ActiveCell = c; this.Selected.Add(c); } }
Thank you for your feedback. I am glad that you resolved your issue and I believe that other community members may benefit from this as well.
Thanks again.