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
385
Reading Value from UnBound Check Box
posted

I have the following code in my XAML file:

 

                    <!-- define a style for a check box -->
                    <igDP:XamDataGrid.Resources>
                        <Style TargetType="{x:Type igDP:CellValuePresenter}" x:Key="CheckBoxCell">
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate>
                                        <CheckBox HorizontalAlignment="Center" VerticalAlignment="Center"/>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </igDP:XamDataGrid.Resources>

 

            <igDP:XamDataGrid.FieldLayouts>
                <igDP:FieldLayout>
                    <igDP:UnboundField Label="CheckBox field">
                        <igDP:UnboundField.Settings>
                            <igDP:FieldSettings
                                CellValuePresenterStyle="{StaticResource CheckBoxCell}"/>
                        </igDP:UnboundField.Settings>
                    </igDP:UnboundField>
                </igDP:FieldLayout>
            </igDP:XamDataGrid.FieldLayouts>

 

The check box displays perfectly in the grid.  However when I check or un-check the box the value is always null.  How can I read, from C# code, whether the check box is checked or not?

 

Also is there are way to display the check box on some rows and not others?  Is there a way to do this in C# code?

 

Parents
No Data
Reply
  • 138253
    Offline posted

    Hello,

     

    It has been a while since you have made your post, in case you still need support I will be glad to assist you further. I suppose the other community members can benefit from this answer as well. I have been looking through your post and I suggest you use the following code:

     

    CheckBox cb = Utilities.GetDescendantFromType(CellValuePresenter.FromCell(xamDataGrid1.ActiveCell), typeof(CheckBox), false) as CheckBox;
    bool? isChecked = cb.IsChecked;
    

     

    In order to get the state of the CheckBox in the XamDataGrid’s ActiveCell. As for your other question, you can look in the Feature Browser under xamDataGrid \ Themes and Custom Styles \ Conditional Formatting section and with little modifications you can bind the Visibility of the CheckBox to another value of you Record and, by using a converter, you can return different Visibilities, depending on that Value.

     

    Feel free to write me if you have further questions.

Children
No Data