This topic shows you how to create and add a xamDataPresenter™ control to your Window using procedural code.
To create xamDataPresenter in procedural code:
- Create a Microsoft® Windows® Presentation Foundation Window project.
- In the Solution Explorer, add the following references:
- Infragistics3.Wpf.v7.2.dll
- Infragistics3.Wpf.Editors.v7.2.dll
- Infragistics3.Wpf.DataPresenter.v7.2.dll
- Name the default Grid layout panel in the Window so that you can reference it in the code-behind.
In XAML:
<GridName="layoutRoot"></Grid> - Attach an event handler to the Window's Loaded event.
In XAML:
<Window...Loaded="Window_Loaded"...> - Open the code-behind and place using/Imports directives in your code-behind so you don't have to type out a member's fully qualified name.
In Visual Basic:
ImportsInfragistics.Windows.DataPresenterIn C#:
usingInfragistics.Windows.DataPresenter; - Create a private Window level variable for the xamDataPresenter control.
In Visual Basic:
PrivatexamDataPresenter1 as XamDataPresenterIn C#:
privateXamDataPresenter xamDataPresenter1; - In the Window_Loaded event handler, initialize your private instance of xamDataPresenter and set its BindToSampleData property to True.
In Visual Basic:
xamDataPresenter1 =NewXamDataPresenter()'You can data bind your instance of xamDataPresenter instead of using the built in sample dataxamDataPresenter1.BindToSampleData =TrueIn C#:
xamDataPresenter1 =newXamDataPresenter();//You can data bind your instance of xamDataPresenter instead of using the built in sample dataxamDataPresenter1.BindToSampleData =true; - Add your instance of xamDataPresenter to the Grid layout panel's Children collection.
In Visual Basic:
Me.layoutRoot.Children.Add(xamDataPresenter1)In C#:
this.layoutRoot.Children.Add(xamDataPresenter1); - Run the project to see the xamDataPresenter control populated with sample data

