开发者

WPF alpha threshold

Is there any alpha threshold in WPF? I use brush #01000000 and on some computers it is non-transparent in regard to mouse hit testing (clicking on surface with this brush), but on some other computers it is considered as totaly transparent and mouse click-through. What is the case?

UPD1: @Alain Nope. The IsHitTestVisible property is in开发者_开发百科dependent of alpha click through. Here a body of the border is click throughable on all of computers:

<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>

And here it is not (but still click-throughable on some computers - that is the question):

<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 is True in both cases.


Interestingly, David Anson says in his blog here:

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

That you can just set it to Transparent. I had always used #01000000 like the OP. One of the commonets on David's blog says Transparent didn't work for them. I wonder if this is related to the OP's problem of #0100000 working on some computers and not others. Perhaps there is some difference other than just running it on different computers?


You should be setting that explicitly using the IsHitTestVisible property.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜