随笔-152  评论-346  文章-2  trackbacks-13

Automation vs RaiseEvent


    通过程序触发元素的事件有两种方法,一种是通过系统的Automation,另外一种是通过元素的RaiseEvent方法。
    现在举例说明以上两种方法的用法,以触发按钮的Click事件为例:
    
     Automation

     ButtonAutomationPeer peer = new ButtonAutomationPeer( someButton );
     IInvokeProvider invokeProv =peer.GetPattern( PatternInterface.Invoke )  as IInvokeProvider;
     invokeProv.Invoke();


     RaiseEvent

      someButton.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));


     那么两种方法有什么区别或者说优劣吗?

    Automation在元素为disabled状态下会发生异常,而RaiseEvent则可以正常调用

    原文:http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1329603&SiteID=1


posted on 2007-07-02 17:32 stswordman 阅读(599) 评论(0) 编辑 收藏
 
昵称:stswordman
园龄:5年10个月
粉丝:23
关注:0
<2007年7月>
24252627282930
1234567
891011121314
15161718192021
22232425262728
2930311234

常用链接

我的标签

随笔分类(252)

随笔档案(182)

相册

SQL

积分与排名

  • 积分 - 197911
  • 排名 - 432

最新评论

阅读排行榜

评论排行榜

推荐排行榜