0

I try to understand how commands work in WPF (I am working in Visual studio 2019). I have a button with
Command="{Binding MyMethod}" (in XAML) where MyMethod is a public void method without any arguments.

When run the application and I click the button, nothing happens. Why is that? And how can I fix it?

  • Also: https://learn.microsoft.com/en-us/dotnet/api/system.windows.input.icommand?view=netcore-3.1 – Stefan Jul 22 '20 at 18:15
  • A command is a type of object with an `ICommand` interface. There are quite some tutorials arround. – Stefan Jul 22 '20 at 18:25
  • @Stefan Ok, the link is about the definition of ICommand which doesn't say anything about the usage of ICommand (an example). I checked the question (that I am duplicating) and I cannot say that it is very clear to me (sorry I am a noob :) ). Do you have any simple example of how to implement ICommand with in my example? – Squaresharper Jul 22 '20 at 18:54
  • I understand - for some reason WPF is about commands, but it's made quite difficult, even for professionals. I think this might be a good example, although it's already over-complicated. Nevertheless: check it out, I believe it's a full example: https://www.technical-recipes.com/2016/using-relaycommand-icommand-to-handle-events-in-wpf-and-mvvm/ – Stefan Jul 22 '20 at 19:11
  • super nice Stefan! super nice – Squaresharper Jul 22 '20 at 19:36

0 Answers0