Cra*_*rer 7 wpf events listbox
我有一个显示一些项目的ListBox,在某些模式中,我在其顶部"标记"了一种水印.我用包含不透明度为0.5的TextBlock的边框完成了这个.这一切都很好用.
但是,我仍然希望用户能够单击ListBox中的项目,但如果我单击"标记",它显然会吃掉点击事件,而ListBox则看不到它们.
我该怎么做才能防止这种情况发生?(即允许ListBox查看Click事件)
谢谢,
克雷格
Rob*_*nee 15
您可以使用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>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3211 次 |
| 最近记录: |