hi
I'm using a XamComboEditor in a Child window with a custom ItemTemplate. Here is the code:
<ig:XamComboEditor Grid.Row="5" Grid.Column="1" Margin="10,0,0,0" HorizontalAlignment="Left" Name="cboUser" VerticalAlignment="Center" Width="250" DisplayMemberPath="Name" EmptyText="Select..." SelectionChanged=" cboUser_SelectionChanged" TabIndex="6" >
<ig:XamComboEditor.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Path=Name, Mode=OneTime}" />
<TextBlock Text=" " />
<TextBlock Text="{Binding Path=Surname, Mode=OneTime}" />
</StackPanel>
</DataTemplate>
</ig:XamComboEditor.ItemTemplate>
</ig:XamComboEditor>
When i click on the arrow and see the DropDown all the Items are shown with Name and Surname as from template.
The problem is that when i select an Item, the selected Item is shown only with "Name" not "Name Surname" as per template.
How can i solve this issue????
Thank you
Hi,
I've attached the sample solution.
Basically what I've re-templated the ToggleButton part of the control - took its style from generic.xaml and updated only the definition of its ContentPresenter to use the ItemTemplate that is set and the content is bound to the XmaComboEditor.Selected item. Hire is the code the code for this:
<ContentPresenter x:Name="contentPresenter" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Content="{Binding Source={RelativeSource AncestorType=ig:XamComboEditor}, Path=SelectedItem}" ContentTemplate="{Binding Source={RelativeSource AncestorType=ig:XamComboEditor}, Path=ItemTemplate}" />
Note that this will work only in SL5 because of the relative binding.
Hope this helps,
Hi
Thanks to reply. Yes I can use xamcomboeditor in IsEnabled=false mode. Could you put the examples please??
Thanks
I believe that the control could be re-templated so it shows what you need. But you'll probably have to use it in IsEditable="False" mode. I could try to put a sample on this if you're OK with not using it in editable mode.
Regards,
thanks for the answer.
So there is no way to modify or re-template the DisplayMemberPath ??
Bye
ItemTemplate is applied only for the items in the dropdown. You could create a FullName property on your underlying data. Then set DisplayMemberPath to be the FullName.