Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Change the image in combobox for selected items ?

$
0
0

 Hello ,

  I have combobox in which i am displaying image and textblock. What i want to do is that change the image when user select particular item.

<ComboBox x:Name="CmbSelect" Foreground="#666" BorderBrush="#C5C5C5" SelectedIndex="0" SelectionChanged="CmbSelect_SelectionChanged" MaxWidth="245"><ComboBox.ItemTemplate><DataTemplate><StackPanel Orientation="Horizontal"><Image Width="16" Height="16"><Image.Style><Style TargetType="Image"><Style.Triggers><DataTrigger Binding="{Binding Type}" Value="2"><Setter Property="Source" Value="selfblk.png"></Setter></DataTrigger><DataTrigger Binding="{Binding Type}" Value="1"><Setter Property="Source" Value="calblk.png"></Setter></DataTrigger></Style.Triggers></Style></Image.Style></Image><TextBlock Text="{Binding Name}" MaxWidth="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ComboBox}},
                                      Path=ActualWidth}"></TextBlock></StackPanel></DataTemplate></ComboBox.ItemTemplate></ComboBox>

I am using two image, which image will be shown on the particular item that is depend on the type. Now i want that when user select any item then image for that item will be changed ( a new image, shape is same but just show that it is selected).

How do i can change image when user select item ..?


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>