WPF 路由事件声明及触发

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Vblegend_2013/article/details/82258862
    public class FullScreenEventArgs : RoutedEventArgs
    {
        public Boolean Status { get; set; }
    }
    [Serializable]
    [ComVisible(true)]
    public delegate void FullScreenEventHandler(object sender, FullScreenEventArgs e);
        #region event
        public static readonly RoutedEvent OnFullScreenEvent = EventManager.RegisterRoutedEvent("OnFullScreen", RoutingStrategy.Bubble, typeof(FullScreenEventArgs), typeof(EnergyDiagram));
        /// <summary>
        /// 处理各种路由事件的方法 
        /// </summary>
        public event FullScreenEventHandler OnFullScreen
        {
            //将路由事件添加路由事件处理程序
            add { AddHandler(OnFullScreenEvent, value, false); }
            //从路由事件处理程序中移除路由事件
            remove { RemoveHandler(OnFullScreenEvent, value); }
        }

        /// <summary>
        /// 响应全屏事件
        /// </summary>
        internal void FullScreen(Boolean Status)
        {
            var param = new FullScreenEventArgs();
            param.Status = Status;
            param.RoutedEvent = OnFullScreenEvent;
            param.Source = this;
            RaiseEvent(param);
        }
        #endregion

猜你喜欢

转载自blog.csdn.net/Vblegend_2013/article/details/82258862