Hi @Hui Liu-MSFT ,
Thanks for the solution.
I will take a look and apply your idea into my solution. I am very appreciate your help on this.
Thanks,
devLearning
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi,
I have a combobox that has a list of items. The combobox is binded to an ObservableCollection. Each item has a button on the right. This purpose of the button is for user to click and delete the item. Currently, when I click the button, nothing gets fire. Please see xaml attached. 198320-filters.xml
Hi @Hui Liu-MSFT ,
Thanks for the solution.
I will take a look and apply your idea into my solution. I am very appreciate your help on this.
Thanks,
devLearning
I can't reproduce your problem. You could try to refer to the example below.
MainWindow.xaml:
<Window.DataContext>
<local:ViewModel />
</Window.DataContext>
<Window.Resources>
<DataTemplate x:Key="ComboBoxItemTemplate" >
<Grid Width="{Binding ElementName=cb,Path=Width }">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="8*"/>
<ColumnDefinition Width="2*"/>
</Grid.ColumnDefinitions>
<TextBlock x:Name="EntityName" Text="{Binding Name}" />
<Image Visibility="{Binding ISShow}" Grid.Column="1" Source="delete.png" HorizontalAlignment="Center" >
<Image.InputBindings>
<MouseBinding Gesture="LeftClick"
Command="{Binding DataContext.MyCommand,
RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}"
CommandParameter="{Binding}"/>
</Image.InputBindings>
</Image>
</Grid>
</DataTemplate>
</Window.Resources>
<Grid>
<ComboBox Name="cb" ItemsSource="{Binding Path=Books}" Width="200" Height="40"
ItemTemplate="{StaticResource ComboBoxItemTemplate}"
SelectedValue="{Binding SelectedItem ,Mode=TwoWay}" >
</ComboBox>
</Grid>
MainWindow.xaml.cs:
The result:
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our [documentation][5] to enable e-mail notifications if you want to receive the related email notification for this thread.
[5]: https://learn.microsoft.com/en-us/answers/articles/67444/email-notifications.html