0
XamcomboEditorで作業したいです。 手順例でステップが見つかりませんでした XamComboEditorでcrud操作を実行します。 誰でもxamcomboeditorの簡単な説明を教えてください。編集モードでXamComboEditorにテキストを設定する方法
XamcomboEditorで作業したいです。 手順例でステップが見つかりませんでした XamComboEditorでcrud操作を実行します。 誰でもxamcomboeditorの簡単な説明を教えてください。編集モードでXamComboEditorにテキストを設定する方法
これはサードパーティ製のコントロールであり、会社のサイトでコードとサンプルを見つけることができます。 Xam combo Editor
XAML
<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>
C#
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)
{
}
}