Version

Please note that this control has been retired and is now obsolete to the XamDataGrid control, and as such, we recommend migrating to that control. It will not be receiving any new features, bug fixes, or support going forward. For help or questions on migrating your codebase to the XamDataGrid, please contact support.

Adding xamGrid to Your Page

Before You Begin

This topic is designed to get you up and running as quickly as possible by describing the basic steps required for adding the xamGrid™ control to your page using procedural code and XAML.

Assumptions:

This topic assumes that you have already configured a data source. For more information, see the Data Binding topic.

What You Will Accomplish

You will create a basic xamGrid control with fixed columns and paging functionality. If you want to add additional features, such as editing, to xamGrid, follow the steps in the appropriate topics and add the code to this basic xamGrid sample.

Follow these Steps

  1. Create a Microsoft® WPF™ project.

  1. Add the following NuGet package reference to your project:

    • Infragistics.WPF.Controls.Grids.XamGrid

    For more information on setting up the NuGet feed and adding NuGet packages, you can take a look at the following documentation: NuGet Feeds.

  1. Attach an event handler to the UserControl’s Loaded event.

    In XAML:

    <UserControl Loaded="UserControl_Loaded" … >
  1. Add the following using/Import directives or add a namespace declaration for xamGrid to the opening UserControl tag so that you don’t have to type out a member’s fully qualified name.

    In XAML:

    xmlns:ig="http://schemas.infragistics.com/xaml"

    In Visual Basic:

    Imports Infragistics.Controls.Grids

    In C#:

    using Infragistics.Controls.Grids;
  1. Add an instance of the xamGrid control, naming it MyGrid, to the default Grid layout panel named LayoutRoot. If you are doing this in procedural code, you can handle the user control’s Loaded event and place the corresponding code in the event handler.

    In XAML:

    <Grid x:Name="LayoutRoot" Background="White">
       <ig:XamGrid x:Name="MyGrid">
          <!-- TO DO: Add xamGrid features -->
       </ig:XamGrid>
    </Grid>

    In Visual Basic:

    Dim MyGrid As New XamGrid()

    In C#:

    XamGrid MyGrid = new XamGrid();
  1. Bind the xamGrid control to data by setting the ItemSource property. For more information, see the Data Binding topic.

  1. Add the PagerSettings object to the xamGrid control to enable paging. For more information, see the Paging topic.

    Set the following properties:

    In XAML:

    <ig:XamGrid.PagerSettings>
       <ig:PagerSettings AllowPaging="Top" PageSize="5"/>
    </ig:XamGrid.PagerSettings>

    In Visual Basic:

    MyGrid.PagerSettings.AllowPaging = PagingLocation.TopMyGrid.PagerSettings.PageSize = 5

    In C#:

    MyGrid.PagerSettings.AllowPaging = PagingLocation.Top;
    MyGrid.PagerSettings.PageSize = 5;
  1. Add the FixedColumnSettings object to the xamGrid control to enable fixed columns. For more information, see the Fixed Columns topic.

    Set the AllowFixedColumns property to Both.

    In XAML:

    <ig:XamGrid.FixedColumnSettings>
       <ig:FixedColumnSettings AllowFixedColumns="Both"/>
    </ig:XamGrid.FixedColumnSettings>

    In Visual Basic:

    MyGrid.FixedColumnSettings.AllowFixedColumns = FixedColumnType.Both

    In C#:

    MyGrid.FixedColumnSettings.AllowFixedColumns = FixedColumnType.Both;
  1. Add the instance of xamGrid to the Grid panel’s Children collection.

    In Visual Basic:

    Me.LayoutRoot.Children.Add(MyGrid)

    In C#:

    this.LayoutRoot.Children.Add(MyGrid);
  1. Save and run your application. You should have a xamGrid control, with paging and fixed columns enabled.