鼠标指向的TreeView项 [英] TreeView item pointed by the mouse

查看:55
本文介绍了鼠标指向的TreeView项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用拖放功能开发Silverlight应用程序,在这里我需要获取鼠标指向的TreeViewItem的详细信息.在放置期间未选择TreeViewItems.所以我不想使用SelectedItem属性.

I am working on a Silverlight Application with Drag and Drop, where I need to get the TreeViewItem''s details pointed by the mouse. The TreeViewItems are not selected during the drop. So I don''t want to use SelectedItem property. Is there any easier way to do that?

推荐答案

在SL中编写应用程序时,我遇到了同样的问题.好吧,除了这个,我没有找到更好的方法.

您将必须使用一个模板,其子控件将处理MouseEnter和MouseOut(我忘记了确切的事件名称).在MouseEnter事件中,您将设置全局项,在MouseOut事件中,将其设置为null.

例如


I had the same problem when I was writing application in SL. Well I didn''t find any better way but this one.

You will have to use a Template whose child control will handle MouseEnter and MouseOut(I forgot exact event names). In MouseEnter event you will set the global item and in MouseOut you will set it to null.

eg


MyItem item = null;
void MouseEnter(.....)
{
// you can also check for MouseDown before doing any further
item = ....;// set your item using sender
}

void MouseOut(....)
{
item = null;
}


这篇关于鼠标指向的TreeView项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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