WPF中有没有alpha阈值?我使用笔刷#01000000,在一些计算机上,它在鼠标点击测试(用这个笔刷点击表面)方面是不透明的,但在其他一些计算机上,它被认为是完全透明的,鼠标点击通过。是什么情况呢?
UPD1:@Alain Nope。IsHitTestVisible属性独立于alpha单击直达。在这里,可以在所有的计算机上点击边框的主体:
<Window
x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" WindowStyle="None" AllowsTransparency="True" Background="Transparent">
<Border BorderBrush="Red" BorderThickness="20" Background="#00000000" IsHitTestVisible="True"/>
</Window>这里不是(但在一些计算机上仍然可以点击-这是问题所在):
<Window
x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" WindowStyle="None" AllowsTransparency="True" Background="Transparent">
<Border BorderBrush="Red" BorderThickness="20" Background="#01000000" IsHitTestVisible="True"/>
</Window>在这两种情况下,IsHitTestVisible都为真。
发布于 2011-09-22 00:20:56
有趣的是,David Anson在他的博客中说:
http://blogs.msdn.com/b/delay/archive/2011/08/18/invisible-pixels-are-just-as-clickable-as-real-pixels-tip-use-a-transparent-brush-to-make-quot-empty-quot-parts-of-a-xaml-element-respond-to-mouse-and-touch-input.aspx
您可以将其设置为透明。我一直使用#01000000作为操作符。David博客上的一个评论说透明对他们不起作用。我想知道这是否与OP #0100000在一些计算机上工作而不是在其他计算机上工作的问题有关。也许除了在不同的计算机上运行它之外,还有一些不同?
发布于 2011-09-22 00:11:35
您应该使用IsHitTestVisible属性显式设置它。
https://stackoverflow.com/questions/7503018
复制相似问题