Hi,
How to put a XamComboEditor and a XamTextEditor into a cell side-by-side, like the image:
Which use the XamTextEditor to input the selection items' index, and use the XamComboEditor to make the selection.
When Editing finished the cell ,which is container of the 2 controls, only display the combo-box's content.
I put a custom contorl, which made up by a XamComboEditor and a XamTextEditor, into the Cell's EditorStyle, this custom control only can render itself when editing start, however, it cannot communicate with the the container cell. After edit, the cell still displayed as blank.
Should I change the Template of CellValuePresenter or use other trick?? Please give me any suggestion! Thanks!
Hello,
There are many ways to do this actually. Here is one quick way to do this:
1.Retemplate the XamTextEditor :
<Style TargetType="{x:Type igEditors:XamTextEditor}" x:Key="style">
<Setter Property="EditTemplate">
<Setter.Value>
<ControlTemplate TargetType="{x:Type igEditors:XamTextEditor}">
<!-- see the default style from the DefaultStyles\Editors directory in the Infragistics folder and place a combo box next to the TextBox. -->
<StackPanel Orientation="Horizontal">
<TextBox Name="PART_FocusSite" .. />
<ComboBox x:Name="combo" SelectionChanged="ComboBox_SelectionChanged">
<ComboBoxItem>1</ComboBoxItem>
<ComboBoxItem>2</ComboBoxItem>
<ComboBoxItem>3</ComboBoxItem>
<ComboBoxItem>4</ComboBoxItem>
<ComboBoxItem>5</ComboBoxItem>
</ComboBox>
</StackPanel>
2. Handle the SelectionChanged event of this ComboBox like this:
private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
xamDataGrid1.ActiveCell.Value = (e.AddedItems[0] as ComboBoxItem).Content;
xamDataGrid1.ExecuteCommand(DataPresenterCommands.EndEditModeAndAcceptChanges);
}
You can also retemplate the Template (if you want the combo box to be visible when the cell is not in edit mode.
3. You can set a x:key to the style (so you can assign it to a particular field). Without a key, it will apply to all the XamTextEditors.
Hope this helps,Alex.
Any thoughts on this issue, also welcome! I am new to WPF.