An 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 following shows how to use the XamComboEditor in various ways
<Window x:Class="XamComboEditorSnippets_cs.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:igEditors="http://infragistics.com/Editors"
xmlns:igDP="http://infragistics.com/DataPresenter"
Title="Window1" Height="300" Width="300">
<Window.Resources>
<ObjectDataProvider MethodName="GetValues"
ObjectType="{x:Type sys:Enum}"
x:Key="VisibilityValues">
<ObjectDataProvider.MethodParameters>
<x:Type TypeName="Visibility" />
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
<!-- This is an ItemsProvider that can be shared by many XamComboEditors. In this
example it is just bound to values of the Visibility enum. -->
<igEditors:ComboBoxItemsProvider x:Key="ComboItemsProvider"
ItemsSource="{Binding Source={StaticResource VisibilityValues}}"/>
</Window.Resources>
<Grid>
<DockPanel LastChildFill="True">
<!-- the first XamComboEditor is using the ItemsProvider defined as a shared resource
above -->
<igEditors:XamComboEditor x:Name="XamComboEditor1" DockPanel.Dock="Top"
DropDownButtonDisplayMode="Always"
SelectedItemChanged="XamComboEditor1_SelectedItemChanged"
ItemsProvider="{StaticResource ComboItemsProvider}"/>
<!-- the second XamComboEditor is defining its own ItemsProvider inline
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. -->
<igEditors:XamComboEditor x:Name="XamComboEditor2" DockPanel.Dock="Top"
ValueType="{x:Type sys:Int32}">
<igEditors:XamComboEditor.ItemsProvider>
<igEditors:ComboBoxItemsProvider >
<igEditors:ComboBoxItemsProvider.Items>
<igEditors:ComboBoxDataItem DisplayText="Item 1" Value="1"/>
<igEditors:ComboBoxDataItem DisplayText="Item 2" Value="2"/>
<igEditors:ComboBoxDataItem DisplayText="Item 3" Value="3"/>
</igEditors:ComboBoxItemsProvider.Items>
</igEditors:ComboBoxItemsProvider>
</igEditors:XamComboEditor.ItemsProvider>
</igEditors:XamComboEditor>
<!-- 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 used above. 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.-->
<igDP:XamDataGrid x:Name="XamDataGrid1" BindToSampleData="True">
<igDP:XamDataGrid.FieldLayouts>
<igDP:FieldLayout>
<igDP:FieldLayout.Fields>
<igDP:UnboundField Name="Visibility Setting" DataType="{x:Type sys:Enum}">
<igDP:UnboundField.Settings>
<igDP:FieldSettings EditorType="{x:Type igEditors:XamComboEditor}">
<igDP:FieldSettings.EditorStyle>
<Style TargetType="{x:Type igEditors:XamComboEditor}">
<Setter Property="ItemsProvider" Value="{DynamicResource ComboItemsProvider}"/>
<Setter Property="DropDownButtonDisplayMode" Value="MouseOver"/>
</Style>
</igDP:FieldSettings.EditorStyle>
</igDP:FieldSettings>
</igDP:UnboundField.Settings>
</igDP:UnboundField>
</igDP:FieldLayout.Fields>
</igDP:FieldLayout>
</igDP:XamDataGrid.FieldLayouts>
</igDP:XamDataGrid>
</DockPanel>
</Grid>
</Window>
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