惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

P
Proofpoint News Feed
Vercel News
Vercel News
T
Tailwind CSS Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - 聂微东
Hugging Face - Blog
Hugging Face - Blog
WordPress大学
WordPress大学
S
SegmentFault 最新的问题
小众软件
小众软件
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Apple Machine Learning Research
Apple Machine Learning Research
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
人人都是产品经理
人人都是产品经理
Google DeepMind News
Google DeepMind News
Engineering at Meta
Engineering at Meta
B
Blog RSS Feed
U
Unit 42
Y
Y Combinator Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
The Register - Security
The Register - Security
量子位
C
CXSECURITY Database RSS Feed - CXSecurity.com
P
Privacy & Cybersecurity Law Blog
Scott Helme
Scott Helme
GbyAI
GbyAI
Know Your Adversary
Know Your Adversary
月光博客
月光博客
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Stack Overflow Blog
Stack Overflow Blog
S
Secure Thoughts
L
Lohrmann on Cybersecurity
腾讯CDC
P
Palo Alto Networks Blog
MongoDB | Blog
MongoDB | Blog
T
Tor Project blog
博客园_首页
W
WeLiveSecurity
G
Google Developers Blog
K
Kaspersky official blog
爱范儿
爱范儿
V
Visual Studio Blog
T
Threat Research - Cisco Blogs
Simon Willison's Weblog
Simon Willison's Weblog
F
Fortinet All Blogs
T
The Exploit Database - CXSecurity.com
N
News and Events Feed by Topic
Last Week in AI
Last Week in AI
aimingoo的专栏
aimingoo的专栏
A
About on SuperTechFans

博客园 - syuko

【转】IE8 松散耦合进程框架探索 【转】Windows 文件夹的秘密:Windows 目录到底占用了多少真实的硬盘空间 【转】d:DesignInstance, d:DesignData in Visual Studio 2010 Beta2 RadTreeView:How to Get Item by Path visual studio 2005 中的部署 产生“不可恢复的生成错误” Windows 7使用记事及琐事流水帐-职称英语考试始末记事 Oracle难道不能处理大数据并发的问题 [转载]DNS解析错误解决办法 鼠标(Mouse)的复数问题告诉我们治学要严谨 Just for Fun-生存,社会秩序,娱乐 软件创作 VB6.0通过SoapToolkit访问WebService问题 [转] oracle rownum 探析 用MSIL来写一个“Hello World” 天地生人,有一人莫不有一人之业;人生在世,有一日当尽一日之勤 小窥黄鹤楼 JavaScript基础之继承(二) JavaScript基础之继承(附实例) JavaScript基础之对象
RadTreeViewItem - event MouseLeftButtonDown or Up never fires
syuko · 2011-03-18 · via 博客园 - syuko

这是借用TeleriK官网论坛上的帖子名字。由于自己也碰到了这个问题,当时也是看了官方的回复才解决的。废话不多说直接说应用场景和解决方案。

应用场景:需要在RadTreeView实现点击节点响应事件,并且当前节点处于Selected状态下点击仍然能触发响应事件。

  (原文:I bound the RadTreeViewItem.MouseLeftButtonDown to an event handler in code, but in debug I noticed the event never fires. I didn't use the RadTreeViewItem.Selected event because when a the item is selected, when use click the item again the Selected event don't fire - this is not I want, so I have to handle the MouseLeftButtonDown or Up events but... the two events never fire. Help!)

解决方案:通常情况下会使用RadTreeView的SelectionChanged事件,但该时间只有在改变当前选中节点的时候才能触发,并且设置节点的IsSelected=true时也会被触发(这个点在做节点定位的时候非常不方便,定位到节点后设置节点的IsSelected=true时会触发SelectionChanged),所以SelectionChanged事件在这个场景里不适用。

  在项目中习惯性的使用MouseLeftButtonDown事件发现竟然不触发,这点很无语呀。

  看了Telerik官方的回复发现官方使用MouseLeftButtonUp事件来处理这个场景。Telerik没解释为什么用Up事件而不是Down事件,有可能Telerik在实现控件的时候没有去获取当前节点,只是在Up事件的时候才去获取。

  代码:

private void TreeViewRoot_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            ObjTreeNodeClass oNodeEnt = TreeViewRoot.SelectedItem as ObjTreeNodeClass;
            if (null == oNodeEnt)
            {
                return;
            }

            //处理逻辑

       }

  对这个处理方式真是很无语,没办法是用别人的控件就得遵守别人的规则,不管别人的规则有时是多么的别扭。