Glossary Item Box
A popular editor to add to a Field is a ComboBox. Attaching a ComboBox to a Field allows end users to select new values for a Cell by selecting a value from a predefined list. To attach a ComboBox to a Field in the xamDataPresenter™, you need to make a custom ControlTemplate for the xamTextEditor™. Assign the custom ControlTemplate to the Field in the xamDataPresenter by setting the EditorStyle property off the FieldSettings object.
The following procedure assumes you have a data bound xamDataPresenter, where you want a field to allow for a combobox to be displayed to aid in the changing of the fields value. For more information, see Creating xamDataPresenter in XAML, the Employees.xml file is used instead of the Orders.xml.
In XAML:
<Style TargetType="{x:Type igEditors:XamTextEditor}"
x:Key="customComboBoxEditor">
<Setter Property="EditTemplate">
<Setter.Value>
<ControlTemplate TargetType="{x:Type igEditors:XamTextEditor}">
<StackPanel>
<ComboBox x:Name="cboComboboxEditor"
Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Text, Mode=TwoWay}"
IsEditable="True"
SelectedItem="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Text, Mode=TwoWay}">
<ComboBoxItem>Quality Assurance</ComboBoxItem>
<ComboBoxItem>Accounting</ComboBoxItem>
<ComboBoxItem>Development</ComboBoxItem>
<ComboBoxItem>Sales</ComboBoxItem>
</ComboBox>
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Grid.Resources>
In XAML:
<igDP:XamDataPresenter x:Name="XamDataPresenter1"
...
>
<igDP:XamDataPresenter.View>
<igDP:GridView/>
</igDP:XamDataPresenter.View>
...
</igDP:XamDataPresenter>
In XAML:
<igDP:XamDataPresenter.FieldLayoutSettings>
<igDP:FieldLayoutSettings AutoGenerateFields="False" />
</igDP:XamDataPresenter.FieldLayoutSettings>
<igDP:XamDataPresenter.FieldLayouts>
<igDP:FieldLayout>
<igDP:FieldLayout.Fields>
<igDP:Field Name="name" Label="Employee's Name"/>
<igDP:Field Name="department" Label="Department">
<igDP:Field.Settings>
<igDP:FieldSettings
EditorStyle="{StaticResource customComboBoxEditor}" />
</igDP:Field.Settings>
</igDP:Field>
</igDP:FieldLayout.Fields>
</igDP:FieldLayout>
</igDP:XamDataPresenter.FieldLayouts>
