'Declaration Public Class XamComboEditor Inherits TextEditorBase Implements ISupportsSelectableText
public class XamComboEditor : TextEditorBase, ISupportsSelectableText
XamComboEditor is a value editor that displays a list of items in a drop down from which the user can select an entry. The editor also supports entering any arbitrary value in the edit portion.
The way you populate items in the drop-down of this editor is by creating a ComboBoxItemsProvider object and setting the editor's ItemsProvider property. ComboBoxItemsProvider exposes ItemsSource and Items properties just like an ItemsControl for specifying items either by binding to an external collection of items using ItemsSource property or directly populating the Items property.
The default ValueType for this editor is string. However, you can set the data type to a different type.
using Infragistics.Windows.Editors; using Infragistics.Windows.DataPresenter; public partial class Window1 : Window { public Window1() { InitializeComponent(); // the first XamComboEditor is using the ItemsProvider defined as a shared // resource in xaml this.XamComboEditor1.ItemsProvider = this.Resources["ComboItemsProvider"] as ComboBoxItemsProvider; this.XamComboEditor1.DropDownButtonDisplayMode = DropDownButtonDisplayMode.Always; this.XamComboEditor1.SelectedItemChanged += new RoutedPropertyChangedEventHandler<object>(XamComboEditor1_SelectedItemChanged); // the second XamComboEditor is defining its own ItemsProvider and // making use of the ComboBoxDataItem helper class to easily define // a separate DisplayText and Value for each item. Alternatively, // you can set the ItemsSource to any IEnumerable and set the // DisplayMemberPath and ValuePath properties to achieve the same effect. ComboBoxItemsProvider provider = new ComboBoxItemsProvider(); for (int i = 0; i < 6; i++) provider.Items.Add( new ComboBoxDataItem(i, "Item " + i.ToString())); this.XamComboEditor2.ValueType = typeof(int); this.XamComboEditor2.ItemsProvider = provider; // The following shows a XamDataGrid that adds an unbound field that // sets its EditorStyle to a XamComboEditor that uses the same shared // ItemsProvider that was defined in xaml. This leverages the significant // speed and memory footprint advantages of using a single shared // ItemsProvider for each record in the XamDataGrid. Note: this can // also be used for standard bound Fields as well. UnboundField fld = new UnboundField(); fld.Name = "Visibility Setting"; Style style = new Style(typeof(XamComboEditor)); style.Setters.Add(new Setter(XamComboEditor.ItemsProviderProperty, new DynamicResourceExtension("ComboItemsProvider"))); fld.Settings.EditorStyle = style; fld.Settings.EditorType = typeof(XamComboEditor); FieldLayout fieldLayout = new FieldLayout(); fieldLayout.Fields.Add(fld); this.XamDataGrid1.FieldLayouts.Add(fieldLayout); this.XamDataGrid1.BindToSampleData = true; } private void XamComboEditor1_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e) { } }
Imports Infragistics.Windows.Editors Imports Infragistics.Windows.DataPresenter Class Window1 Public Sub New() ' This call is required by the Windows Form Designer. InitializeComponent() ' Add any initialization after the InitializeComponent() call. ' the first XamComboEditor is using the ItemsProvider defined as a shared ' resource in xaml Me.XamComboEditor1.ItemsProvider = TryCast(Me.Resources("ComboItemsProvider"), ComboBoxItemsProvider) Me.XamComboEditor1.DropDownButtonDisplayMode = DropDownButtonDisplayMode.Always AddHandler Me.XamComboEditor1.SelectedItemChanged, AddressOf XamComboEditor1_SelectedItemChanged ' the second XamComboEditor is defining its own ItemsProvider and ' making use of the ComboBoxDataItem helper class to easily define ' a separate DisplayText and Value for each item. Alternatively, ' you can set the ItemsSource to any IEnumerable and set the ' DisplayMemberPath and ValuePath properties to achieve the same effect. Dim provider As ComboBoxItemsProvider = New ComboBoxItemsProvider() For i As Int32 = 0 To 8 provider.Items.Add(New ComboBoxDataItem(i, "Item " + i.ToString())) Next Me.XamComboEditor2.ValueType = GetType(Integer) Me.XamComboEditor2.ItemsProvider = provider ' The following shows a XamDataGrid that adds an unbound field that ' sets its EditorStyle to a XamComboEditor that uses the same shared ' ItemsProvider that was defined in xaml. This leverages the significant ' speed and memory footprint advantages of using a single shared ' ItemsProvider for each record in the XamDataGrid. Note: this can ' also be used for standard bound Fields as well. Dim fld As UnboundField = New UnboundField() fld.Name = "Visibility Setting" Dim styl As Style = New Style(GetType(XamComboEditor)) styl.Setters.Add(New Setter(XamComboEditor.ItemsProviderProperty, New DynamicResourceExtension("ComboItemsProvider"))) fld.Settings.EditorStyle = styl fld.Settings.EditorType = GetType(XamComboEditor) Dim fl As FieldLayout = New FieldLayout() fl.Fields.Add(fld) Me.XamDataGrid1.FieldLayouts.Add(fl) Me.XamDataGrid1.BindToSampleData = True End Sub Private Sub XamComboEditor1_SelectedItemChanged(ByVal sender As System.Object, ByVal e As System.Windows.RoutedPropertyChangedEventArgs(Of System.Object)) End Sub End Class
Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2