Take the 2-minute tour ×

I have a combobox with few items displayed as image and text (placed side by side for each item). Now when i select an item from the combobox list i want to display something else (instead of same image and text) maybe another text or another image on the Combobox selecteditem area.

Is there a way i can achieve it.

share|improve this question
I want to change the appearence whent he combobox is collapsed and the selecteditem is shown on the combobox. –  deepak Jul 24 '09 at 9:49
add comment

2 Answers

The easiest way is to add an IsSelected Trigger to the DataTemplate(Itemstemplate) of the Combobox, I think you have two groups of Visual elements one for the regular data display and another for the selected visuals, When IsSelected property set on the ComboboxItem you need to Make the regular visuals hide and the other one show. The real trick here is to find the immediate ComboBoxItem user selected using FindAncestor .

<DataTemplate x:Key="yourDataTemplate">
 <Grid x:Name="regularVisuals" > ... </Grid>
 <Grid x:Name="selectedVisuals" Visibility="Collapsed"> ... </Grid>
    <DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type ComboBoxItem}},Path=IsSelected}" Value="True">
        <Setter TargetName="regularVisuals" Property="Visibility" Value="Visible"/>
        <Setter TargetName="selectedVisuals" Property="Visibility" Value="Collapsed"/>

share|improve this answer
Should the TargetName of both Setter 's really read selectedVisuals? Shouldnt one be regularVisuals? –  mizipzor Oct 15 '09 at 14:52
You are right @mizipzor Thank you for pointing that out, –  Jobi Joy Oct 15 '09 at 16:37
add comment

There are several possible ways, one of them is using DataTemplates and Data template selectors.

share|improve this answer
add comment

Your Answer


