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
475
Enabling Edit Template when Checkbox is checked
posted

I have a XamGrid that has a CheckColumn. How do I enable the edit template of another column if the value of the checkbox is checked?

This is how my XamGrid looks like:

https://ibb.co/cDRPBQ

When I check one of the box, how will I activate the edit template of the 'Import Action' column of the checked row programatically? The end result should look something like:

https://ibb.co/gkAZBQ

Thanks!

Parents
  • 530
    Offline posted

    Hello ErikaB,

     

    You can use EnterEditMode method when checkbox is checked on CheckBoxColumn. In order to handle checked event on CheckBoxColumn, you can use CellControlAttached event.

     

            private void XamGrid1_CellControlAttached(object sender, CellControlAttachedEventArgs e)

            {

                if(e.Cell.Column is CheckBoxColumn)

                {

                    (e.Cell.Control.Content as System.Windows.Controls.CheckBox).Checked -= CheckBoxControl_Checked;

                    (e.Cell.Control.Content as System.Windows.Controls.CheckBox).Checked += CheckBoxControl_Checked;

     

                    (e.Cell.Control.Content as System.Windows.Controls.CheckBox).Unchecked -= CheckBoxControl_Unchecked;

                    (e.Cell.Control.Content as System.Windows.Controls.CheckBox).Unchecked += CheckBoxControl_Unchecked;

                }

            }

     

    If the checkbox is checked, call EnterEditMode.

     

            private void CheckBoxControl_Checked(object sender, RoutedEventArgs e)

            {

                CheckBox cb = e.Source as CheckBox;

                if (cb.IsChecked == true)

                {

                    var row = FindParent<CellControl>(cb).Cell.Row;

                    Cell cell = row.Cells["ProductName"] as Cell;

     

                    this.Dispatcher.BeginInvoke((Action)(() =>

                    {

                        this.xamGrid1.EnterEditMode(cell); }

                    ));

                }

            }

     

    EnterEditMode Method
    https://es.infragistics.com/help/wpf/infragisticswpf4.controls.grids.xamgrid.v16.2~infragistics.controls.grids.xamgrid~entereditmode

     

    CellControlAttached Event
    https://es.infragistics.com/help/wpf/infragisticswpf4.controls.grids.xamgrid.v16.2~infragistics.controls.grids.xamgrid~cellcontrolattached_ev

    Best regards,
    Yuki Mita
    Developer Support Engineer
    Infragistics Inc.
    www.infragistics.com/support

    WpfApp1.zip
Reply Children