So I\'ve been searching around and cannot find out exactly how to do this. I\'m creating a user control using MVVM and would like to run a command on the \'Loaded\' event.
Well, if the DataContext is already set you could cast it and call the command:
var viewModel = (MyViewModel)DataContext; if (viewModel.MyCommand.CanExecute(null)) viewModel.MyCommand.Execute(null);
(Change parameter as needed)