Hi,
I'm following the section "Changing the Default Column and Row Definitions" from the NetAdvantage for WPF documentation.
I'd like to show the data in a double row, with the first 4 fields up and the 5th below :
______________________
Field1 Field2 Field3 Field4
Field5
----------------------------------------
I'm trying to follow the documentation but I'm getting an exception. I'm using this code:
<igDp:XamDataGrid DataSource="{Binding Store}" DockPanel.Dock="Top" AutoFit="True" Name="TheGrid"> <igDp:FieldLayoutSettings AutoArrangeCells="Never" AutoGenerateFields="False" /> <igDp:XamDataGrid.FieldLayouts> <igDp:FieldLayout> <igDp:FieldLayout.Fields> <igDp:Field Name="LoggerName" Row="0" Column="0"/> <igDp:Field Name="Level" Row="0" Column="1"/> <igDp:Field Name="TimeSpan" Row="0" Column="2"/> <igDp:Field Name="Formatted" Row="0" Column="3"/> <igDp:Field Name="Formatted" Row="1" Column="0" ColumnSpan="4" IsExpandable="True"/> </igDp:FieldLayout.Fields> </igDp:FieldLayout> </igDp:XamDataGrid.FieldLayouts> </igDp:XamDataGrid>
But I' getting this exception:
Can't set the DataSource on a DataPresenter that has items added explicitly through the DataItems collection.System.InvalidOperationException: Can't set the DataSource on a DataPresenter that has items added explicitly through the DataItems collection. at Infragistics.Windows.DataPresenter.DataPresenterBase.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at Infragistics.Windows.DataPresenter.XamDataGrid.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
What is the problem? Can't I use databinding?
Cheers.
Probably the problem is the binding of the data and surely in the code-behind file. Please follow this link http://help.infragistics.com/Help/NetAdvantage/WPF/2008.2/CLR3.X/html/WPF_Data_Binding.html and make sure that the grid is bound correctly. If you still have any problems paste me the code-behind file or better the whole solution to take a closer look.
Humm... there is not code behind for that grid, actually I changed the code to this:
<igDp:XamDataGrid DataSource="{Binding Store}" DockPanel.Dock="Top" AutoFit="True"> <igDp:XamDataGrid.FieldLayouts> <igDp:FieldLayout> <igDp:FieldLayout.Fields> <igDp:Field Name="LoggerName" Row="0" Column="0"/> <igDp:Field Name="Level" Row="0" Column="1"/> <igDp:Field Name="TimeSpan" Row="0" Column="2"/> <igDp:Field Name="Formatted" Row="1" Column="0" ColumnSpan="3" IsExpandable="True"/> </igDp:FieldLayout.Fields> </igDp:FieldLayout> </igDp:XamDataGrid.FieldLayouts> </igDp:XamDataGrid>
I've removed the name of the xamDataGrid for be sure nobody is calling it from the code behind, and I've removed this line:
<igDp:FieldLayoutSettings AutoArrangeCells="Never" AutoGenerateFields="False" />
And then is working, there is not exception, but the data is not shown as I want, what could be the problem?