现在的位置: 首页 > 综合 > 正文

wpf中如何监测每个window

2012年09月10日 ⁄ 综合 ⁄ 共 325字 ⁄ 字号 评论关闭

使用全局的EventManager的RegisterClassHandler函数,如:

public partial class App : Application
    {
        protected void MyLoaded(object source, RoutedEventArgs e)
        {
            object s = e.Source;

        }
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            EventManager.RegisterClassHandler(typeof(Window), Window.LoadedEvent, new RoutedEventHandler(MyLoaded), true);
        }
    }
}

抱歉!评论已关闭.