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
1935
MVVM and XamDataGrid
posted

I'm new to Infragistics and I therefore have a question regarding MVVM and databinding in the XamDataGrid.

What I need to know is, how I have to write the XAML for the DataGrid in order to bind properties to the columns of the grid?

I have set the DataContext of my MainWindow to an instance of a class containing a ObservableCollection with the items that I want to display. I then set the DataSource of the XamDataGrid to "{Binding Calculations}". But this apparently isn't enough...

I would also like to know how to get an instance of the selected item?

Current XAML:

<igDP:XamDataGrid
            Grid.Row="1"
            x:Name="MyGrid"
            DataSource="{Binding Calculations}"
            AssigningFieldLayoutToItem="MyGrid_AssigningFieldLayoutToItem">
            <igDP:XamDataGrid.FieldSettings>
                <igDP:FieldSettings
                    CellClickAction="SelectRecord"
                    AllowEdit="True" />
            </igDP:XamDataGrid.FieldSettings>
            <igDP:XamDataGrid.FieldLayouts>
                <igDP:FieldLayout Key="master">
                    <igDP:Field Name="ShortName" />
                    <igDP:Field Name="Name" />
                    <igDP:Field Name="Min" />
                    <igDP:Field Name="Prob" />
                    <igDP:Field Name="Max" />
                    <igDP:Field Name="Mean" />
                </igDP:FieldLayout>
                <igDP:FieldLayout Key="nested">
                    <igDP:Field Name="ShortName">
                        <igDP:Field.Settings>
                            <igDP:FieldSettings LabelPresenterStyle="{StaticResource MyStyle}" />
                        </igDP:Field.Settings>
                    </igDP:Field>
                    <igDP:Field Name="Name">
                        <igDP:Field.Settings>
                            <igDP:FieldSettings LabelPresenterStyle="{StaticResource MyStyle}" />
                        </igDP:Field.Settings>
                    </igDP:Field>
                    <igDP:Field Name="Min">
                        <igDP:Field.Settings>
                            <igDP:FieldSettings LabelPresenterStyle="{StaticResource MyStyle}" />
                        </igDP:Field.Settings>
                    </igDP:Field>
                    <igDP:Field Name="Prob">
                        <igDP:Field.Settings>
                            <igDP:FieldSettings LabelPresenterStyle="{StaticResource MyStyle}" />
                        </igDP:Field.Settings>
                    </igDP:Field>
                    <igDP:Field Name="Max">
                        <igDP:Field.Settings>
                            <igDP:FieldSettings LabelPresenterStyle="{StaticResource MyStyle}" />
                        </igDP:Field.Settings>
                    </igDP:Field>
                    <igDP:Field Name="Mean">
                        <igDP:Field.Settings>
                            <igDP:FieldSettings LabelPresenterStyle="{StaticResource MyStyle}" />
                        </igDP:Field.Settings>
                    </igDP:Field>
                </igDP:FieldLayout>
            </igDP:XamDataGrid.FieldLayouts>
        </igDP:XamDataGrid>