I am new to WPF and I've been searching all over the internet and have not found a solution to my problem. My question is, how do you call a method not in the code behind but from another class using Commands? Am I correct that Commands are the only way to call methods from another class? I know you can simply make an object reference inside the button click, but I don't want to do that due the complexity of my project.
Let's say I want to call the Print function from ClassA using the Command function inside the button in MainWindow.xaml, how can I achieve this?
ViewModel: ClassA.cs
public class ClassA
{
Print()
{
Console.WriteLine("Hello");
}
}
View: MainWindow.xaml
<button Command=? ><button/>