Creating control over transparent click events

I have a ListBox displaying some elements, and in certain modes I "stamp" a kind of watermark on top of it. I did this with a border containing a text block with an opacity of 0.5. All of this works great.

However, I still want the user to be able to click on items in the ListBox, but if I click on the “stamp”, he clearly eats click events and they are not visible to the ListBox.

What do I need to do to prevent this? (i.e. let the ListBox see the Click event)

Thanks,

Craig

+5
source share
1 answer

IsHitTestVisible:

<Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <ListBox>
        <ListBoxItem>a</ListBoxItem>
        <ListBoxItem>b</ListBoxItem>
        <ListBoxItem>c</ListBoxItem>
    </ListBox>
    <Border Opacity="0.2" Background="Cyan" BorderBrush="Black" BorderThickness="5" IsHitTestVisible="False" >
        <TextBlock Text="EXAMPLE" FontSize="20" HorizontalAlignment="Center" VerticalAlignment="Center"/>
    </Border>
</Grid>
+13

All Articles