Has somebody a good example to create a UserControl, and then bind commands to it?
My problem is to forward the command to a control in the UserControl, for example to a TreeView’s Drop event. It’s not clear, how can I do that.
Both answer are interesting and thanks, they help, but…
I want something like that:
The usage:
<my:MyControl Command="{Binding XCommand}" CommandParameter="{Binding [Here what?]}"/>
The control contains the two DependencyProperties, Command and CommandParameters, and I’d like to bind these two DependecyProperties to a TreeView – Drop event. How can I do that? Because the usage of the CommandParameter is reversed: not the control passes a parameter, but the users wants something: CommandParameter=”{Binding Text, ElementName=DisableCommandTextBox}”
Unfortunately, we cannot bind a RelayCommand within a viewmodel directly to the Drop event due to the limitations on TreeView.
However, this problem has been previously solved. Take a look at this link to see how it was done. If you’d like an example of a more typical command binding (to a button perhaps), leave a comment below and I’ll add that in.