如何在WPF C#Visual Studio中将单击事件用于标签或文本块? [英] How to use click event for label or textblock in wpf c# visual studio?

查看:328
本文介绍了如何在WPF C#Visual Studio中将单击事件用于标签或文本块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理桌面应用程序,我得到建议使用wpf代替winforms.我想在单击标签时转到另一种窗体/窗口,但是找不到标签和文本块的单击事件?谁能告诉我鼠标左移事件是做什么用的?

I am working on desktop application i got suggestion to use wpf instead winforms. I want to go to another form/window when i click my label but i cant find click event for label and textblock? also can anyone tell me what is left mouse up event used for?

推荐答案

还有谁能告诉我鼠标左移事件是做什么用的?

also can anyone tell me what is left mouse up event used for?

例如,它可以用于按需处理TextBlock的点击:

It can for example be used to handle the click of a TextBlock like you want:

<TextBlock Text="..." MouseLeftButtonUp="TextBlock_MouseLeftButtonUp" />

如文档中所述,当鼠标指针悬停于此元素上并且鼠标左键释放时,就会发生此事件:

This event occurs when the left mouse button is released while the mouse pointer is over this element as stated in the documentation: https://msdn.microsoft.com/en-us/library/system.windows.uielement.mouseleftbuttonup(v=vs.110).aspx

您还可以处理MouseLeftButtonDown事件: 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆