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
332
CellControl of unbound column return null
posted

Hi,

I added an unbound column contains CheckBox. Xaml for this as below:

 

 

 

 

<ig:UnboundColumn Key="Select"> 

 

 

 

 

 

<ig:UnboundColumn.HeaderTemplate>

 

 

 

 

<DataTemplate>

 

 

 

 

<CheckBox x:Name="chkHeaer" Checked="chkHeaer_Checked" Unchecked="chkHeaer_Unchecked"/>

 

 

 

 

</DataTemplate>

 

 

 

 

</ig:UnboundColumn.HeaderTemplate> 

 

 

 

 

<ig:UnboundColumn.ItemTemplate> 

 

 

 

 

<DataTemplate> 

 

 

 

 

<CheckBox x:Name="chk" Checked="SelectRowCheckBox_Checked" Unchecked="SelectRowCheckBox_UnChecked"/> 

 

 

 

 

</DataTemplate

 

 

 

 

</ig:UnboundColumn.ItemTemplate 

 

 

 

 

</ig:UnboundColumn> 

 <ig:UnboundColumn Key="Select">

 

 

 

 

 

<ig:UnboundColumn.HeaderTemplate>

<DataTemplate>

<CheckBox x:Name="chkHeaer" Checked="chkHeaer_Checked" Unchecked="chkHeaer_Unchecked"/>

</DataTemplate> 

 

 

 

 

</ig:UnboundColumn.HeaderTemplate> 

 

 

 

 

<ig:UnboundColumn.ItemTemplate>

 

 

 

 

<DataTemplate>

<CheckBox x:Name="chk" Checked="SelectRowCheckBox_Checked" Unchecked="SelectRowCheckBox_UnChecked"/>

</DataTemplate>

 

 

 

 

</ig:UnboundColumn.ItemTemplate>

 

 

 

 

</ig:UnboundColumn>  

 

Header checkbox checked/UnChecked event is 

private void chkHeaer_Checked(object sender, RoutedEventArgs e) {


      CheckBox chk = sender as CheckBox;
      foreach (Row row in grdBase.Rows) {


        if (row.Cells[0].Control != null) {
          CheckBox chkBox = ((CellControlBase)(row.Cells[0].Control)).Content as CheckBox;
          chkBox.IsChecked = true;
        }


      }


    } 

 

   private void chkHeaer_Unchecked(object sender, RoutedEventArgs e) {
      CheckBox chk = sender as CheckBox;
      foreach (Row row in grdBase.Rows) {
        if (row.Cells[0].Control != null) {
          CheckBox chkBox = ((CellControlBase)(row.Cells[0].Control)).Content as CheckBox;
          chkBox.IsChecked = false;
        }
      }
    }

 

But on chkHeaderchekced/Unchecked event some of rows cell control have null references. i.e.

row.Cells[0].Control return null. so i am unable to get these rows checkbox references.

Can any one let me know why this happens or I am doing something wrong?

 

Parents Reply Children
No Data