2011-09-21 100 views
0

WPF中是否有任何alpha閾值?我使用筆刷#01000000,並且在某些計算機上,它對於鼠標點擊測試(使用此筆刷單擊表面時)是不透明的,但在其他一些計算機上,它被視爲完全透明且鼠標點擊。情況如何?WPF alpha閾值

UPD1:@Alain Nope。 IsHitTestVisible屬性與alpha點擊無關。這裏邊境的身體是點擊throughable在所有計算機上的:

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

這裏,它不是(但仍然點擊throughable在某些計算機上 - 這是個問題):

<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在兩種情況下都是正確的。

回答

0

您應該明確使用IsHitTestVisible屬性進行設置。

1

有趣的是,大衛·安森說,在這裏他的博客:

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像OP。大衛博客上的一個共同點是透明的並不適合他們。我想知道這是否與OP的#0100000在某些計算機而不是其他計算機上工作有關。也許除了在不同的計算機上運行它之外,還有一些不同之處?

+0

默認情況下,該值爲{x:Null},不需要鼠標輸入。將筆刷設置爲透明可以響應鼠標輸入。 –

+0

很遺憾,我不在靠近電腦的地方,因爲我遇到了穩定的問題。我有兩臺電腦,通過相同的ClickOnce鏈接執行相同的程序。其中一個出現問題(點擊),另一臺電腦正常。關於透明畫筆。我的觀察結果是,透明畫筆不能在同一個PresentationSource(一個窗口)的邊界內點擊。我需要使用AllowsTransparency =「True」的窗口,在這種情況下,只有#01000000刷子才能使透明,但不能點擊通過表面。透明刷在這種情況下不起作用。 –

+0

啊,我明白你在說什麼維克多。點擊WPF窗口中的一個元素到同一個窗口中的另一個元素之間的區別,與點擊整個WPF窗口到另一個應用程序後面的區別。對? – Tim