0
Answer

Combobox & SelectedItem

Ask a question
Tuan Le

Tuan Le

11y
1.8k
1
Hi,
I have a DataTemplate:
< DataTemplate >
   <Grid>
        <StackPanel Orientation="Horizontal" >
            <Image Source="{Binding SomeImage}" />
            <TextBlock Text={"Bingding SomeText}" />
       </StackPanel>
    </Grid>
< /DataTemplate>

And a toggleButton:
< ToggleButton IsChecked = "{Binding SomeBinding, Mode = TwoWay}" > 
     <ToggleButton.Content>
         <Image Source="{Bingding Path=SelectedValue />
     </ToggleButton.Content>
< /ToggleButton>

And a combobox:
< ComboBox ItemSource="{Binding SomeItemSource}" ItemTemplate="{StaticResource ComboboxItemTemplate}"
           SelectedItem="{Binding SelectTedItemActive}" SelectedValuePath="SelectTedValueImage">
< /ComboBox>

In the code behind:

ItemSource:
      SomeItemSource contains two data: Image1 and Image2
SelectedItem:
      SelectedItemActive is a property.

When I run the application and press the combobox, it pops up with Imag1 and Image2 and I can choose one of them,

If I now choose Image1 and next time I choose Image2 (Image1 -> Image2), the code go to SelectTedItemActive
because of selectedValuechange.

If I now choose Image1 and next time I choose Imag1 (Image1 -> Image1), the code NOT go to SelecttedItemAvive because is not selectedValuechange.

My question is how can I force the code to go to SelectTedItemActive although is not selectedValuechange (Image1 -> Image1)? Thanks you very much.