Hi,
XamComboEditor internally uses a ComboBox in its edit template. You can specify a style to apply to this combo box using the XamComboEditor's ComboBoxStyle property. This is where you can specify any properties like the ItemTemplate that you want to apply to the combo box.
Hope this helps,
Sandip
Can we get a more elaborate response.
I'm very confused as to how to apply an Items Template for when the XamComboEditor is expanded and then show a different Template to when it's closed. It seems that the ComboBox control does this rather easy and I'm wondering why it seems harder to do using the XamComboBox control.
Thanks
The XamComboEditor uses a WPF ComboBox while in edit mode. It exposes a property named ComboBoxStyle which can be used to set the Style whose TargetType is ComboBox and is used to set any properties that you would have set on the ComboBox itself such as ItemTemplate, etc. If you still encounter a problem then please post a sample demonstrating the problem along with a description of what you are trying to accomplish.
Hi Andrew,
While I can use the Style property and apply a DataTemplate to the Combo, it raises an error -
System.Windows.Data Error: 24 : Both 'ContentTemplate' and 'ContentTemplateSelector' are set; 'ContentTemplateSelector' will be ignored. ComboBoxItem:'ComboBoxItem' (Name='')
I am assuming that XamComboEditor or the Combo itself is setting some values for the ItemTemplate and ItemTemplateSelector, which in turn feeds the ContentTemplates? (I am new to WPF)
Is there anyway to do this safely with the XamComboEditor?
Zack
Excuse my ignorance, I had the DisplayMemberPath still set.....d'uh.
Hi All.. I have the following code that allows me to put a tamplate for the drop down items. How do I then write a template for when the combobox is then closed. I would expect it to be like ItemsTemplateSelector or something but I couldn't get it to work
<igEditors:XamComboEditor ItemsSource="{Binding Users}" ValuePath="Name" Value="{Binding User}" Margin="34,129,0,112" Name="xamComboEditor2" HorizontalAlignment="Left" Width="200">
<igEditors:XamComboEditor.ComboBoxStyle>
<Style TargetType="ComboBox">
<Setter Property="ItemTemplate">
<Setter.Value>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Name}" Width="100" />
<TextBlock Text="{Binding Phone}" Width="100" />
</StackPanel>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
</igEditors:XamComboEditor.ComboBoxStyle>
</igEditors:XamComboEditor>
The issue you are having is that you don't see the ItemsTemplate you specified being used when its closed (while still in edit mode or not) or that you want to have a different template for what is displayed in the edit area?
I will create a support case on your behalf so that we can continue the discussion there.
Hi Alex. I know we have to similiar threads working the same problem. It seems the grid in the combo it proving to be to complicated.
What I'm trying to mimic is the following example I have using a ComboBox. I can't seem to mirror the same functionality with a XamComboBox.
Basically I have a Users List with 3 columns. Name, Phone and SocialSecurity number. I bind it as the Item Source (athough I would plan to use and ItemsProvider if I can get this to work for the XamComboEditor. Using the Items template selector I either want to show it one way (when the combo is opened with the 3 columns. or another when the user selects a comboItem (just one column). How do I do this with the XamCombo? Essentially this is exaactly what I want but I want to use your control.
Here is my xaml.
<ComboBox Margin="138,39,20,0" Name="comboBox1" ItemsSource="{Binding Users}" SelectedValuePath="Name" SelectedValue="{Binding User}" Height="23" VerticalAlignment
="Top">
<ComboBox.ItemTemplateSelector
>
<WPFSandbox:TemplateSelector
/>
</ComboBox.ItemTemplateSelector
<ComboBox.Resources
<DataTemplate x:Key
="DropDownTemplate">
<StackPanel Orientation
="Horizontal">
<TextBlock Text="{Binding Name}" Width
="100" />
<TextBlock Text="{Binding Phone}" Width
<TextBlock Text="{Binding SocialSecurity}" Width
</StackPanel
</DataTemplate
="SelectionTemplate">
</ComboBox.Resources
Here is the Template Selector:
DataTemplateSelector
{
container)
)container;
)
);
// Templated parent is ComboBoxItem
</ComboBox
Thanks again for all the help.. Sorry for the multiple posts..
This is because the XamComboEditor has not ended its edit mode and the value is not updated until then. It ends edit mode when you click away (lose focus), so you need to force it to end edit mode when you select an item:
x.EndEditMode(true,true);
You have not provided any code-behind (the part where you select an item) so I really cannot give you the exact code, but you should call the EndEditMode(...) of the XamComboEditor when the item is selected.
Hi Alex. If I set the DisplayMember prop it does show the correct item when I click away from the ComboBox. The problem is when I select the item it then shows that entire item in the combobox till I click away. How do we make it so it just shows the one item as if I did click away?
I know you did something like this in the other example but since it's mixed up with all the gris stuff I couldn't figure out what to do. Can you look at the sample code I attached in my previous post give an example from that?
Thanks for all the help..
Hello,
I believe this is the DisplayText property. You can create a converter (IValueConverter) for the ValueToDisplayText property of the XamComboEditor.
I have created a sample with a XamComboEditor with XamDataGrid inside it, and when a record from the XamDataGrid is selected, only one column is displayed as text.
You can see that on the thread below (a sample included also):
http://community.infragistics.com/forums/t/26793.aspx
Hope this helps.