本文介绍了列表视图的WPF MouseMove事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的WPF应用程序,我面临的问题,当鼠标移动到在mousemove事件不同的项目,从列表视图获取项目。
例如说,如果列表视图中包含的项目列为
一
二
三
----然后在鼠标移动时,如果我的鼠标移动在该项目上两人随后我在我的code拿到二。请帮助我,我很新的这上头。
问候
拉维
解决方案
这可能是一个非常简单的解决方案,但它似乎做你想要做的事。
私人无效listView_MouseMove(对象发件人,MouseEventArgs E)
{
VAR项目= Mouse.DirectlyOver; 如果(项目= NULL&放大器;!&安培;产品的TextBlock)
Debug.Print((项目作为TextBlock的)。文本);
}
我希望这有助于。
In my wpf application, i am facing problem to get item from listview when mouse is moved over different items in mousemove event. Say for example if listview contains item listed as ,
"one"
"two"
"three"
----
Then in mousemove event if my mouse moved over the item two then i have to get "two" in my code.
Please help me as i am very new to this WPF.
Regards
Ravi
解决方案
This might be a very simplistic solution, but it does seem to do what you want it to do.
private void listView_MouseMove(object sender, MouseEventArgs e)
{
var item = Mouse.DirectlyOver;
if (item != null && item is TextBlock)
Debug.Print((item as TextBlock).Text);
}
I hope this helps.
这篇关于列表视图的WPF MouseMove事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!