0
votes

The xaml below works correctly when I click (MouseDown) anywhere on the background of the listbox. The problem is that I can not get it to work when I click on any single item in the listbox. I've tried putting the trigger code inside the border, image or TextBlock with no success.

<ListBox Name="SelectL2List" ItemsSource="{Binding L2Items, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsSynchronizedWithCurrentItem="True">
    <i:Interaction.Triggers>
        <i:EventTrigger EventName="MouseDown">
            <si:CallDataMethod Method="HideSelectL2View" Target="{Binding}" />
        </i:EventTrigger>
    </i:Interaction.Triggers>
    <ListBox.ItemsPanel>
        <ItemsPanelTemplate>
            <WrapPanel IsItemsHost="True" />
        </ItemsPanelTemplate>
    </ListBox.ItemsPanel>
    <ListBox.ItemTemplate>
        <DataTemplate DataType="{x:Type ViewModels:MediaItemViewModel}" >
            <Border BorderThickness="1,1,3,3" Margin="10" CornerRadius="3">
                <StackPanel Orientation="Horizontal" >
                    <Image Source="{Binding Image}"/>
                        <TextBlock Text="{Binding L2Title}" />
                    </StackPanel>
                </Border>
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>

Any help would be appreciated.

1

1 Answers

0
votes

You have to make sure that things are hit testing as well, you can set the Background of the Border to Transparent to ensure that.

Also the mouse events are intercepted by the ListBoxItems, use the tunneling versions, i.e. PreviewMouseDown.