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!
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 Methodhttps://es.infragistics.com/help/wpf/infragisticswpf4.controls.grids.xamgrid.v16.2~infragistics.controls.grids.xamgrid~entereditmode
CellControlAttached Eventhttps://es.infragistics.com/help/wpf/infragisticswpf4.controls.grids.xamgrid.v16.2~infragistics.controls.grids.xamgrid~cellcontrolattached_ev
Best regards,Yuki MitaDeveloper Support EngineerInfragistics Inc.www.infragistics.com/support
Thank you for your answer. It worked okay when checking a checkbox one at a time. However, in my example, my checkbox column has a header template, which also contains a checkbox. If this checkbox is checked, all of the checkboxes per row are checked and the expected behavior is that all the rows' editor template will activate. Right now, it activates only the last row like the image below:
https://ibb.co/mnSc0k
The expected behavior is that the entire column "Import Action" will enter into Edit Mode. How do I do that?
XamGrid can show editor on a single cell or a single row. In your scenario, I would suggest you to put both Label and TextBox in ItemTemplate of TemplateColumn. And based on the checked state of the corresponding cell on the same row, determine which control to be visible. In this way, you can show multiple editable controls on XamGrid. For details, please refer to the updated sample.
If you have any question with this, please let me know.
Thanks for your help :)