I created a fieldlayout in the backend and I am trying to display it in a XamDataGrid, but the fields I created won't display. As a matter of fact, nothing appears on the grid. What seems to be my problem?
XamDataGrid
Here is my xaml code:
<Window x:Class="WpfApplication1.MainWindow" xmlns="">schemas.microsoft.com/.../presentation" xmlns:x="">schemas.microsoft.com/.../xaml" Title="MainWindow" Height="350" Width="525" xmlns:igWPF="">schemas.infragistics.com/.../wpf"> <Grid> <Grid> <DockPanel LastChildFill="True" Margin="0,26,0,-26"> <igWPF:XamDataGrid x:Name="Account_Info_XamDataGrid"> </igWPF:XamDataGrid> </DockPanel> </Grid> </Grid> </Window>
and the backend:
private void ShowAccountInfoGrid() { ComboBoxItemsProvider title_provider = new ComboBoxItemsProvider(); ComboBoxItemsProvider code_provider = new ComboBoxItemsProvider(); List<Acc_LinkDTO> Acc_lists = new List<Acc_LinkDTO>(); Acc_lists = _Acc_LinkUIAdapter.getAllAcc_Links().ToList(); accounts = _AccountUIAdapter.getALlGroup(); Account_Info_XamDataGrid.FieldLayouts.Clear(); foreach (var x in Acc_lists) { int i = 0; title_provider.Items.Add(new ComboBoxDataItem(i, x.Acc_LinkTitle)); i++; } foreach (var x in accounts) { int i = 0; code_provider.Items.Add(new ComboBoxDataItem(i, x.Code2)); name_provider.Items.Add(new ComboBoxDataItem(i, x.Name)); i++; } //First column Field fld1 = new Field(); fld1.Name = "Account Title"; Style style1 = new Style(typeof(XamComboEditor)); style1.Setters.Add(new Setter(XamComboEditor.ItemsProviderProperty, title_provider)); fld1.Settings.EditorStyle = style1; fld1.Settings.EditorType = typeof(XamComboEditor); fieldLayout.Fields.Add(fld1); Account_Info_XamDataGrid.FieldLayouts.Add(fieldLayout); }
If you want to utilize your FieldLayout with an IEnumerable set to the DataSource of your grid, make sure that the Name attributes of the Field match up with a property on your underlying data item.