Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
755
Changing the Default Column and Row Definitions
posted

 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.

Parents
  • 54937
    Verified Answer
    Offline posted

    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>

Reply Children