C
C#2y ago
Kosta

❔ How does the execution pipeline works with interfaces that implement methods?

Lets say we have the icommand interfact, it has to methods : canExcute and Excute, When i bind said command to a button and click it, How does it know to go into the execute method? whats going on behind? Who is responsible for telling the code to go into that methode and where can i find it?
3 Replies
atakancracker
atakancracker2y ago
There should be set of execution logic from .net System.Windows services. You can search the classes implements ICommad interface from System.Windows soruce code and see where does it get called maybe
Kosta
Kosta2y ago
But again, how does it know to go into that method? is there a bit of code that tells it "becuase you implemented this interface you need to go into the execute method"? I mean chatgpt gave me this unsure if its correct: The button knows to invoke the Execute method of the ICommand because that is the standard behavior defined by the WPF framework for buttons that are bound to a command. When you bind an ICommand implementation to a button in XAML, the framework automatically sets up the necessary event handlers and bindings to ensure that the button invokes the Execute method of the command when it is clicked. The process works as follows: The button's Click event is raised when the button is clicked by the user. The framework looks for a command that is bound to the button via the Command property. If a command is found, the framework invokes the Execute method of the command. This is a standard behavior of the WPF framework, and it is defined in the Button class, which is the base class for all buttons in WPF. The implementation details of this behavior are part of the WPF framework code and can be found in the .NET source code, but you do not typically need to interact with these details directly in your own code.
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.