'Declaration Public Property ItemsSource As IEnumerable
public IEnumerable ItemsSource {get; set;}
There are two ways you can specify the items to display in the drop-down of the XamComboEditor. You can set the ItemsSource property to a collection of items to display in the drop-down or you can add items to the collection returned Items property. Note that you can not do both at the same time. When you specify the ItemsSource property, the Items property will return a collection that's read-only. It will reflect the same items as the ItemsSource however it will be read-only. Any changes made to the ItemsSource will also be reflected by the Items property.
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