xmlns:ig="http://schemas.infragistics.com/xaml"
This topic demonstrates how to add a xamMultiColumnComboEditor™ control to your application and use some of its properties.
You need to first read the following topics:
The following table lists some of the configurable behaviors of the xamMultiColumnComboEditor control.
Add the Infragistics namespace.
Add required references
In order to add a xamMultiColumnComboEditor to your application you must add a reference to the following NuGet package:
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.
Add the Infragistics namespace
In XAML:
xmlns:ig="http://schemas.infragistics.com/xaml"
In Visual Basic:
Imports Infragistics.Controls.Editors
In C#:
using Infragistics.Controls.Editors;
Add a xamMultiColumnComboEditor control.
In XAML:
<ig:XamMultiColumnComboEditor/>
In Visual Basic:
Dim multiColumnCombo As XamMultiColumnComboEditor = New XamMultiColumnComboEditor()
In C#:
XamMultiColumnComboEditor multiColumnCombo = new XamMultiColumnComboEditor();
In order to… |
Use this property: |
And set it to… |
Populate xamMultiColumnComboEditor with items |
An IEnumerable data source |
Set the ItemSource property
In XAML:
<ig:XamMultiColumnComboEditor ItemsSource="[your IEnumerable source]"/>
In Visual Basic:
multiColumnCombo.ItemsSource = "[your IEnumerable source]"
In C#:
multiColumnCombo.ItemsSource = "[your IEnumerable source]";
The following table maps the desired configurations to property settings. The properties are directly accessed from the xamMultiColumnComboEditor control.
Let the control to generate the columns.
An important part of setting up the xamMultiColumnComboEditor control is to generate the columns. You can let the control generate the columns automatically by:
In XAML:
<ig:XamMultiColumnComboEditor AutoGenerateColumns="True"/>
In Visual Basic:
multiColumnCombo.AutoGenerateColumns = True
In C#:
multiColumnCombo.AutoGenerateColumns = true;
Set which column value is displayed when the dropdown is closed.
In order to define the property used by the control to display the selected items, set the DisplayMemberPath property of the control equal to the property name.
In XAML:
<ig:XamMultiColumnComboEditor DisplayMemberPath="[Property Name]"/>
In Visual Basic:
multiColumnCombo.DisplayMemberPath = "[Property Name]"
In C#:
multiColumnCombo.DisplayMemberPath = "[Property Name]";
Define the columns displayed in the dropdown of the control (when AutoGenerateColumns is set to False).
If you want to choose and arrange the columns in the control manually, set the AutoGenerateColumns property to false and then set the Columns Collection for the xamMultiColumnComboEditor control:
In XAML:
<ig:XamMultiColumnComboEditor.Columns>
<ig:TextComboColumn Key="ContactName"/>
<ig:TextComboColumn Key="Company"/>
</ig:XamMultiColumnComboEditor.Columns>
In Visual Basic:
multiColumnCombo.AutoGenerateColumns = False
Dim colContactName = New TextComboColumn()
Dim colCompany = New TextComboColumn()
colContactName.Key = "ContactName"
colCompany.Key = "Company"
multiColumnCombo.Columns.Add(colConactName)
multiColumnCombo.Columns.Add(colCompany)
In C#:
multiColumnCombo.AutoGenerateColumns = false;
var colContactName = new TextComboColumn();
var colCompany = new TextComboColumn();
colContactName.Key = "ContactName";
colCompany.Key = "Company";
multiColumnCombo.Columns.Add(colContactName);
multiColumnCombo.Columns.Add(colCompany);
Allow the user to select more than one item in the control.
If you want to let the user to select more than one item from the xamMultiColumnComboEditor, set the AllowMultipleSelection property to true.
In XAML:
<ig:XamMultiColumnComboEditor AllowMultipleSelection="True"/>
In Visual Basic:
multiColumnCombo.AllowMultipleSelection = True
In C#:
multiColumnCombo.AllowMultipleSelection = true;
Display checkboxes in front of every item.
If you want to let the user to select more than one item from the xamMultiColumnComboEditor, set the AllowMultipleSelection property to true.
In XAML:
<ig:XamMultiColumnComboEditor CheckBoxVisibility="Visible"/>
In Visual Basic:
multiColumnCombo.CheckBoxVisibility = System.Windows.Visibility.Visible
In C#:
multiColumnCombo.AllowMultipleSelection = System.Windows.Visibility.Visible;
The selected items can be retrieved by using the following:
Get all the selected items collection.
When the AllowMultipleSelection property is set to true, you can retrieve the selected items collection by accessing the SelectedItems property:
In Visual Basic:
Dim selItems = multiColumnCombo.SelectedItems
In C#:
var selItems = multiColumnCombo.SelectedItems;
Get or Set the selected item
Get a selected item
When the AllowMultipleSelection property is set to false you can get the selected item by accessing the SelectedItem property:
In Visual Basic:
Dim selItem = multiColumnCombo.SelectedItem
In C#:
int selItem = multiColumnCombo.SelectedItem;
Set a selected item
When the AllowMultipleSelection property is set to false you can set the selected item by assigning an instance of an item from the data source collection equal to the SelectedItem property:
In XAML:
<ig:XamMultiColumnComboEditor SelectedItem="[an item from the data model]"/>
In Visual Basic:
multiColumnCombo.SelectedItem = [an item from the data model]
In C#:
multiColumnCombo.SelectedItem = [an item from the data model];
Get or Set the selected index
Get a selected index
You can get the selected index by accessing the SelectedIndex property:
In Visual Basic:
Dim selIndex = multiColumnCombo.SelectedIndex
In C#:
int selIndex = multiColumnCombo.SelectedIndex;
Set a selected index
You can set the selected index by assigning an index value to the SelectedIndex property:
In XAML:
<ig:XamMultiColumnComboEditor SelectedIndex="[your index value]"/>
In Visual Basic:
multiColumnCombo.SelectedIndex = [your index value]
In C#:
multiColumnCombo.SelectedIndex = [your index value];
Following are some other topics you may find useful.