I’ve created a WPF UserControl which contains a Button. I now want any consumer of the usercontrol to be able to set a Command property on the usercontrol, and for that command to be assigned to the button within the control. i.e. so that when the button is clicked, it runs the command (in this case a Prism DelegateCommand).
So, my UserControl looks like:
<UserControl>
<Button ...>
</UserControl>
and my consumer, I wish to look like:
<controls:ThreeStateImageButtonControl
Command="..." />
You need to create a dependency property for Command on your control, then create an event handler for the button’s Click event to execute Command. Then users can bind to Command. Perhaps a web tutorial or documentation would help you do that? Maybe google “WPF dependency property on user control tutorial” or some such thing.
However, I’m not sure you are doing the right thing. If your user control has nothing but a Button inside it, you may want to consider a custom control that inherits from Button instead; the implementation would be simpler, and users could just use the Click event in the normal way. There are also WPF custom control tutorials on the web in many places.
By the way, your property won’t be actually called Command, right?