zoukankan      html  css  js  c++  java
  • 简单的应用路由事件

    简单的定义下面的路由事件类,死东西,敲熟练

      public class MyRoutedEvents : UIElement
        {
            public static readonly RoutedEvent ButtonClickEvent = EventManager.RegisterRoutedEvent("ButtonClick", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(MyRoutedEvents));
    
            public event RoutedEventHandler ButtonClick
            {
                add { AddHandler(ButtonClickEvent, value); }
                remove { RemoveHandler(ButtonClickEvent, value); }
            }
    
            public void SendEvent(RoutedEvent evt, RoutedEventArgs e)
            {
                e.RoutedEvent = evt;
                RaiseEvent(e);
            }
    
            public virtual void OnButtonClick()
            {
                SendEvent(ButtonClickEvent, new RoutedEventArgs());
            }
        }
    View Code

    前台需要一个控件的事件来激活

     private void img__MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
            {
                MyRoutedEvents routed = new MyRoutedEvents();
                routed.ButtonClick += new RoutedEventHandler((object sender2, RoutedEventArgs evte) => {
                    MessageBox.Show("Clicked me.");
                });
                routed.OnButtonClick();
            }
    View Code

    ok了。

  • 相关阅读:
    Swagger2 添加HTTP head参数
    获取枚举类型描述
    JS设置cookie、读取cookie、删除cookie
    ES6中Promise的入门(结合例子)
    阮一峰的ES6---Promise对象
    model_util.py
    IfcSpatialElementType
    labelme coco
    python opencv KeyPoint
    IfcSpatialZoneType
  • 原文地址:https://www.cnblogs.com/smartsensor/p/3151974.html
Copyright © 2011-2022 走看看