Version

Adding xamDataPresenter to Your Application

This topic shows you how to create and add a xamDataPresenter™ control to your Window using procedural code.

To create xamDataPresenter in procedural code:

  1. Create a Microsoft® Windows® Presentation Foundation Window project.

  1. Add the following NuGet package to your application:

    • Infragistics.WPF.DataGrids

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. Name the default Grid layout panel so that you can reference it in the code-behind.

    In XAML:

    <Grid Name="layoutRoot">
    </Grid>
  1. Attach an event handler to the Window’s Loaded event if you are going to use the code-behind to add the xamDataPresenter.

    In XAML:

    <Window ... Loaded="Window_Loaded"  ... >
  1. Add a namespace declaration and using/Imports directives for xamDataPresenter.

    In XAML:

    xmlns:igDP="http://infragistics.com/DataPresenter"

    In Visual Basic:

    Imports Infragistics.Windows.DataPresenter

    In C#:

    using Infragistics.Windows.DataPresenter;
  1. Create an instance of xamDataPresenter in XAML or in the Window_Loaded event handler in code-behind. Set the BindToSampleData property to True. This will automatically populate xamDataPresenter with sample data so that you can preview the xamDataPresenter control without setting up a data source.

    In XAML:

    <igDP:XamDataPresenter Name="xamDataPresenter1" BindToSampleData="True" />

    In Visual Basic:

    Private xamDataPresenter1 as XamDataPresenter
    xamDataPresenter1 = New XamDataPresenter()
    ' You can data bind your instance of xamDataPresenter
    ' instead of using the built in sample data
    xamDataPresenter1.BindToSampleData = True
    Me.layoutRoot.Children.Add(xamDataPresenter1)

    In C#:

    private XamDataPresenter xamDataPresenter1;
    xamDataPresenter1 = new XamDataPresenter();
    // You can data bind your instance of xamDataPresenter
    // instead of using the built in sample data
    xamDataPresenter1.BindToSampleData = true;
    this.layoutRoot.Children.Add(xamDataPresenter1);
  1. Run the project to see the xamDataPresenter control populated with sample data.

    creating xamdatapresenter in xaml