I am working on a C#-WPF-App.
When pressing a certain button in a window, a module is loaded. This happens because the Command Property of the button is bound to the LoadModuleCommand in the class "ConfigureViewModel":
<Button Command="{Binding LoadModuleCommand}" Margin="10,10,10,10" Grid.Column="1" Content="Add Module" Grid.Row="0" />
For some reason, which is not important for this question, I now also want to call the same command (i.e. the LoadModuleCommand) from the MainViewModel.cs-file, if a certain condition is true:
if (id.Equals(Module.Id.ToString()))
{
//call the LoadModuleCommand
}
I knew what I had to do, if I had to bind the LoadModuleCommand to a second UI-control. But how do I simply call the command from within c#-code?