Version

Adding xamComboEditor to Your Page

Before You Begin

The following code will show you how to bind to data and display the xamComboEditor™ control. It uses the DataUtil class provided for you.

Note
Note

The xamComboEditor control does not have an unbound mode. You must bind it to a data source.

What You Will Accomplish

This topic will walk you through how to get started with the xamComboEditor control and how to add it to your page using procedural code.

Follow these Steps

  1. Create a Microsoft® WPF™ project.

  1. Add the following NuGet package to your application:

    • Infragistics.WPF.Controls.Editors.XamComboEditor

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. Add the following using/Import directives in the code-behind and a namespace declaration in the opening UserControl tag.

    In XAML:

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

    In Visual Basic:

    Imports Infragistics.Controls.Editors

    In C#:

    using Infragistics.Controls.Editors;
  1. Add the xamComboEditor control to a Grid container named LayoutRoot.

    • Set the xamComboЕditor control’s ItemsSource property to the ObservableCollection of Product objects.

    • Set the DisplayMemberPath property. It specifies the path to a data property of your business object that will be visually displayed in the xamComboEditor items drop-down list.

    • Set the EmptyText property to specify the text that will be displayed when no item is selected.

    • Set the IsEditable property to false to create a read-only xamComboEditor. By default the control is editable and this property is set to true.

    • Set the xamComboEditor control’s Height and Width properties.

    • Set the MaxDropDownHeight property. This property limits the height of the xamComboEditor drop-down list. Otherwise, the available space above and below the control is estimated. By default, the list is displayed below the control. If there is not enough space below, the list is displayed above the control. The drop-down list is restricted within the available height of your WPF application.

    • Adjust the DropDownButtonDisplayMode property. This property configures the drop down button visibility. The possible options are - Always (default), MouseOver, Focused, Never.

      Note
      Note

      Do not use this property when the IsEditable property is set to false.

    • Add the newly created control as a child of the Grid container.

      In XAML:

      <UserControl.Resources>
          <local:DataUtil x:Key="DataUtil" />
      </UserControl.Resources>
      <Grid x:Name="LayoutRoot">
      <ig:XamComboEditor
          ItemsSource="{Binding Source={StaticResource DataUtil}, Path=Products}"
          DisplayMemberPath="ProductName"
          EmptyText="Choose Product ..."
          IsEditable="False"
          Height="30" Width="250"
          MaxDropDownHeight="150" />
      </Grid>

      Create an instance of the xamComboEditor control in the page constructor after the InitializeComponent method.

      In Visual Basic:

      Dim xamComboEditor As New XamComboEditor()
      xamComboEditor.ItemsSource = DataUtil.Products
      xamComboEditor.DisplayMemberPath = "ProductName"
      xamComboEditor.EmptyText = "Choose Product ..."
      xamComboEditor.IsEditable = False
      xamComboEditor.Height = 30
      xamComboEditor.Width = 250
      xamComboEditor.MaxDropDownHeight = 150
      LayoutRoot.Children.Add(xamComboEditor)

      In C#:

      XamComboEditor xamComboEditor = new XamComboEditor();
      xamComboEditor.ItemsSource = DataUtil.Products;
      xamComboEditor.DisplayMemberPath = "ProductName";
      xamComboEditor.EmptyText = "Choose Product ...";
      xamComboEditor.IsEditable = false;
      xamComboEditor.Height = 30;
      xamComboEditor.Width = 250;
      xamComboEditor.MaxDropDownHeight = 150;
      LayoutRoot.Children.Add(xamComboEditor);
  1. Save and run your WPF application.

xamComboEditor Getting Started With xamComboEditor 01.png