Hi,
When using the xamdatagrid field chooser, The datagrid is getting refreshed for each change in the chooser window. But I want to refresh the grid only after closing the field chooser window with multiple selected or deslected fields. Please help on this. I am using 2013.2 version.
Thanks,
Sreek
Hello Sreek,
You can remove the XamCheckEditors value binding from default style of FieldChooser and implement logic where iterate through the Fields and set manually IsVisible property to be equal to the IsChecked of corresponding XamCheckEditor. In order to do that after closing the FieldChooser you can access the ToolWindow from FieldChooser visual tree and handle its Closing event. You can get it in FieldChooserOpening event of XamDataGrid. To do that you can add something like:
private void xdg_FieldChooserOpening(object sender, Infragistics.Windows.DataPresenter.Events.FieldChooserOpeningEventArgs e){ ToolWindow win = Utilities.GetAncestorFromType(e.FieldChooser, typeof(ToolWindow), false) as ToolWindow; win.Closing += new System.ComponentModel.CancelEventHandler(WinClosing);}
public void WinClosing(Object sender, EventArgs e){ FieldChooser fChooser = Utilities.GetDescendantFromType((sender as ToolWindow),typeof(FieldChooser), false) as FieldChooser; if (fChooser == null) return; var checkEditors = FindVisualChildren<XamCheckEditor>(fChooser).Where(edt => edt.IsVisible).ToList(); for (int i = 0; i < fChooser.CurrentFields.Count; i++) { fChooser.CurrentFields[i].IsVisible = (checkEditors[i] as XamCheckEditor).IsChecked ?? false; } }
if (fChooser == null) return;
var checkEditors = FindVisualChildren<XamCheckEditor>(fChooser).Where(edt => edt.IsVisible).ToList();
for (int i = 0; i < fChooser.CurrentFields.Count; i++) { fChooser.CurrentFields[i].IsVisible = (checkEditors[i] as XamCheckEditor).IsChecked ?? false; } }
We ship the default styles in the DefaultStyles directory in the Infragistics folder. The full path for the styles for the FieldChooser should look something like :
C:\Program Files (x86)\Infragistics\NetAdvantage <your version>\WPF\DefaultStyles\DataPresenter.
The FieldChooser style is in the DataPresenterGeneric_Express.xaml file.
I have attached simple sample application, where you can test the suggested approach. Please let me know if you have any more questions.
Sincerely, ZhivkoEntry Level Software Developer
Thanks Zhivko. It doesn't work for my scenario, because after hide/show fields in chooser window, if I open back chooser window, all of the fields are checked.
SO I modified your sample to reproduce the issue.
Field chooser template is modified to show xamdatagrid instead of listbox. and I am trying to use of UpdateSourceTrigger.Explicit property, to trigger the property change manually on the first column(checkbox column) . So When I close the chooser window, then I call the binding.updatesource method for each of xamcheckeditor's binding expression.
In this case, The grid doesn't get refresh for the first change, but if I continue to select /unselect fields, the grid gets refreshed with the previous selected/unselected changes.
Please help.