Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
215
XamDataGrid row selection
posted

I am trying to get the selected rows in a datagrid.

I dont want the user to have to use the row/record selector, so have enabled row selection on any cell.

And i want the user to be able to select multiple rows using ctrl/shift + click.

 

 

 

 <igDataPresenter:XamDataGrid x:Name="dataGrid" DockPanel.Dock="Top"  >

        <igDataPresenter:FieldSettings AllowEdit="False" CellClickAction="SelectRecord" />

        <igDataPresenter:XamDataGrid.FieldLayoutSettings>

            <igDataPresenter:FieldLayoutSettings 

                AutoFitMode="Always" 

                AutoGenerateFields="False"/>

        </igDataPresenter:XamDataGrid.FieldLayoutSettings>

        <igDataPresenter:XamDataGrid.FieldLayouts>

            <igDataPresenter:FieldLayout>

                <igDataPresenter:FieldLayout.Fields>

                    <igDataPresenter:Field Name="MessageNumber" Label="Message Number"   />

 

 

 

i would like to be able to see the selected records (list/collection) in the code behind (when selection changes)

in my DataGrid_CellActivated and DataGridSelectedItemsChanged methods i *should* be able to do "DataGrid.SelectedItems" and see the records that have been selected.

However this is not working.

e.g.

 

I click a cell, the cell activated event fires and 

e.Cell.Record.IsSelected = false

and

e.Cell.IsSelected = false

DataGridSelectedItemsChanged is not fired and (bearing in mind that AllowEdit="False") the cell is put into edit mode.

 

if i ctrl + click another cell

cell activated fires (same results as above) then DataGridSelectedItemsChanged is fired.

but, 

DataPresenter.SelectedItems has one record not two.

The main thing i would like to know is, how should i determine the selected records?

 

thanks.