我可以通过代码隐藏移动鼠标吗? [英] Can I move the mouse by code-behind ?
问题描述
Hi Expression Blend pros,
Hi Expression Blend pros,
我有一个用户控件放在进入组件屏幕,我想在后面的代码中再添加一个函数。可以"放"吗?每当我加载包含组件屏幕时鼠标悬停在此用户控件上?
I have a user control that which was put into a component screen, I want to add one more function in the code behind. Is it possible to "put" the mouse over this user control every time when I load the containing component screen?
我不喜欢不知道是否"加载"是正确的术语,我的意思是当我将组件屏幕(包含此用户控件)的可见性从折叠更改为可见时。
I don't know if "load " is the right term, what I mean here is when I change the visibility of the component screen (which is containing this user control ) from collapsed to visible.
非常感谢!
Thank you very much !
推荐答案
首先,你不应该移动鼠标,鼠标属于用户。但是,有多种方法:
First, you shouldn't move the mouse, the mouse belongs to the user. However, there are multiple ways:
从你的其他线程引用Christine:
Quoting Christine from your other thread:
这是一种方式......
Here is one way...
http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/1ba35ea0-7313-41a4-9a4a-472575f21e46/
,可能是一个更简单的方法,但有点烦人......
and probably a more simple approach but a bit annoying...
http://msdn.microsoft.com/en-us/library/system.windows.forms.cursor.position.aspx
对于第二个,您必须添加System.Windows.Forms.dll和使用System.Windows.Forms语句。
For the second you would have to add the System.Windows.Forms.dll and a using System.Windows.Forms statement.
烦人的部分就是......一旦你这样做,你就会得到一些错误(可能),它们之间有一个"模糊的引用"... .Windows和System.Windows.Forms"
The annoying part is that... as soon as you do that, you'll get some errors (possibly) that there is an "ambiguous reference between... System.Windows and System.Windows.Forms"
要解决它......假设您使用的是MessageBox,则必须将其称为System.Windows.MessageBox.Show()或System.Windows.Forms。 MessageBox.Show()...
To solve it... say you were using a MessageBox, you would have to refer to it as System.Windows.MessageBox.Show() or System.Windows.Forms.MessageBox.Show()...
希望这不会太混乱。
Hope that wasn't too confusing.
~Christine
~Christine
这是烦人的部分。:)
That is the annoying part. :)
这篇关于我可以通过代码隐藏移动鼠标吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!