I am pretty new to Xaml. I want to hide one column "Id" from my XamDataGrid which is bound to a datatable in viewmodel.
I tried the below approach:
private void xamDataGrid1_FieldLayoutInitialized(object sender, Infragistics.Windows.DataPresenter.Events.FieldLayoutInitializedEventArgs e)
{
xamDataGrid1.FieldLayouts[0].Fields["ID"].Visibility = Visibility.Collapsed;
}
But when I run the code first time , I get the below Exception :
System.ArgumentException: 'key not found'
Is there any way to check if the Field["Id"] exists or not before running the above code ?
The below one worked for me :