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.
The xaml you have is incorrect. You're adding the FieldLayoutSettings as a data item instead of setting it as the FieldLayoutSettings of the data presenter.
e.g.
<igDp:XamDataGrid DataSource="{Binding Store}" DockPanel.Dock="Top" AutoFit="True" Name="TheGrid">
<igDp:XamDataGrid.FieldLayoutSettings> <igDp:FieldLayoutSettings AutoArrangeCells="Never" AutoGenerateFields="False" />
</igDp:XamDataGrid.FieldLayoutSettings>
I've changed that line, now there is not exception... but there is no data neither :P
I've build a small project as example, please tell me what am I doing wrong.
http://www.vtortola.net/files/InfragisticsTestProject.zip
Thanks!
There are two problems. First, one of the fields you have defined is using a name that does not exist in the LoggedEntry class. You have "TimeSpan" but the property name is actually "TimeStamp". Correcting this allows the data to show because a matching FieldLayout is now found. The other issue I see is that you have set the IsExpandable property of the Formatted field to true. This will cause its data to be displayed within a child band rather than in the row with the other cells so I think you want to remove that.
Geez... the IsExpandable property was intentionated but the name of the property... I had to be blind... sorry about that :P
Thanks very much.