欧美三区_成人在线免费观看视频_欧美极品少妇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條評論
主站蜘蛛池模板: 欧美日韩国产网站 | 久久久精品免费观看 | 狠狠躁夜夜躁人人爽天天miya | 国产淫语对白在线视频 | 日本中文字幕网站 | 久草.com| 久久精品国产清自在天天线 | 成人 精品 | 9277在线观看视频 | 日韩视频免费 | 亚洲欧美日韩在线不卡中文 | 香港一级毛片免费看 | 免费视频爱爱太爽了 | 日韩一页| 日韩av线| 一级寡妇乱色毛片全18 | 亚洲国产精品久久久久网站 | 精品久久中文字幕 | 亚洲一区二区三区久久 | 国产午夜亚洲精品第一区 | www午夜视频 | 国内色综合精品视频在线 | 色678黄网站全部免费 | 欧美精品一区二区三区在线播放 | 精品99在线 | 日韩经典欧美一区二区三区 | 欧美亚洲精品在线 | 91在线视频播放 | 久久久国产精品福利免费 | 成年免费大片黄在线观看岛国 | 成人在线免费网站 | 久久综合一区二区三区 | 日韩五码在线 | 亚洲高清久久 | 亚洲黄色a | 玖玖精品视频在线观看 | 艹逼网 | 色人阁在线 | 新97人人模人人爽人人喊 | 黄色一级在线视频 | 在线播放一区二区三区 |