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
25
Get checked rows in a xamGrid.
posted

Hello, Experts

I have a xamGrid with a checkbox Column like below.

                    <ig:XamGrid Name="igGridNewLabels">

                                <ig:TemplateColumn.ItemTemplate>

                                    <DataTemplate>                                       

                                       <CheckBox Name="cbSelected" IsChecked="{Binding Selected, Mode=TwoWay}" Margin="25,0,25,0"  Width="20" Click="cbSelected_Click" />

                                    </DataTemplate>

                                </ig:TemplateColumn.ItemTemplate>

                            </ig:TemplateColumn>

 

                           … …

 

                           </ig:XamGrid.Columns>

 

                           … …

    

                    </ig:XamGrid>

 

The problem is I want to get the checked rows in this xamGrid. I use following code to get selected rows.

 

                  foreach (var row in this.igGridNewLabels.Rows)

            {

                CheckBox currentCheckbox = (CheckBox)row.Cells[0].Control.Content;

                if (currentCheckbox.IsChecked.Value)

                {

                    // do something.

                }

            }

 

But the problem when there are too many rows in the xamGrid, that cause the scrollbar appears. I fail to get the checkbox for the rows that are in the hidden in the UI. The row.Cells[0].Control throws an nullreferenceException when the foreach loop execute to the hidden area in the UI.

 

Can you experts help me? This really drive me crazy.

 

PS:  I cannot use DataSource to find the selected rows. Because as you know when the columns are sorted or a filter is applied, the datasource will be inconsistent with UI.

 

Thanks in advance.

 

Any suggestion will be much appreciated!!!

 

Jim