欧美三区_成人在线免费观看视频_欧美极品少妇xxxxⅹ免费视频_a级毛片免费播放_鲁一鲁中文字幕久久_亚洲一级特黄

MouseDown not triggered?

系統 1883 0

In following case:

< Window x : Class ="WpfApplication59.MainWindow"

xmlns ="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

xmlns : x ="http://schemas.microsoft.com/winfx/2006/xaml"

Title ="MainWindow" Height ="350" Width ="525">

< Grid >

< Button HorizontalAlignment ="Center" VerticalAlignment ="Center" MouseDown ="Button_MouseDown"> test </ Button >

</ Grid >

</ Window >

?

public partial class MainWindow : Window

{

public MainWindow()

{

InitializeComponent();

this .AddHandler( Button .MouseDownEvent, new MouseButtonEventHandler (Test), true );

}

?

private void Button_MouseDown( object sender, MouseButtonEventArgs e)

{

Console .WriteLine( "mousedown from button." );

}

?

private void Test( object sender, MouseButtonEventArgs e)

{

Console .WriteLine( "mousedown from test." );

}

}

?

The Button_MouseDown cannot be triggered, because MouseDown is a "bubbling" event, it means that child control on which the event happens handles it first, and only if it
declines to handle it, the event is passed on to the parent of that
control (and so on, until it reaches top). If you want to capture the
event in a parent before the child sees it, you need to use a
"tunneling" event - in your case, it would be PreviewMouseDown.

?

As an alternative approach suggested is adding the line
AddHandler(FrameworkElement.MouseDownEvent, new
MouseButtonEventHandler(Test), true);
to your window's constructor after the call to InitializeComponent (and
remove "MouseDown="Button_MouseDown" from the XAML).

Below is the mainwindow:

MouseDown not triggered?

Click test button, see how the events were handled from snoop:

MouseDown not triggered?

First the preview… event is raised, then mousedown event raised, since the mousedown is already handled by button, so you cannot listen it outside.

?

?

MouseDown not triggered?


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 4438激情网 | 妞干网在线免费观看 | 国产一级大片 | 999久久久| 香港三级台湾三级在线播放徐 | 国产精品久久久天天影视香蕉 | 精品在线一区二区 | 精品一区二区三区不卡 | 国产精品你懂的在线播放 | 亚洲经典激情春色另类 | 日韩精品一区二区三区中文字幕 | 国产精品3区 | 操操影视 | 日韩毛片高清免费 | 91婷婷射 | 特黄免费 | 欧美色欧美亚洲另类二区精品 | 欧美一区黄 | 国产羞羞网站 | 国产精品一二区 | 超碰在线播 | 精品久久久久久一区二区 | 精品国产一区二区三区性色av | 午夜影院操 | 天天色天天射天天操 | 二级黄绝大片中国免费视频 | 99免费视频| 欧美交换乱理伦片120秒 | 国产精品一区二区三区免费 | 国产在线观看一区二区 | 欧美一区二区三区免费视频 | 日本无码少妇波多野结衣 | 偷拍小美女洗澡在线播放 | 免费视频片在线观看大片 | 四虎1515hh海外永久免费在线 | 精品视频第一页 | 免费在线观看黄 | 国产成人久久蜜一区二区 | 午夜寂寞影视在线观看 | 日本va视频| 9191在线 |