How to fire a Command when a window is loaded in wpf

前端 未结 4 1426
Happy的楠姐
Happy的楠姐 2020-12-14 23:08

Is it possible to fire a command to notify the window is loaded. Also, I\'m not using any MVVM frameworks (Frameworks in the sense, Caliburn, Onxy, MVVM Toolkit etc.,)

4条回答
  •  感情败类
    2020-12-14 23:32

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
           ApplicationCommands.New.Execute(null, targetElement); 
           // or this.CommandBindings[0].Command.Execute(null); 
        }
    

    and xaml

        Loaded="Window_Loaded"
    

提交回复
热议问题