Note that there are some explanatory texts on larger screens.

plurals
  1. POExpose multiple command in WPF user control
    text
    copied!<p>A better explanation, I hope:</p> <ul> <li>I have a toolbar with 3 buttons on it, all three bound to a Command (including a CommandParameter)</li> <li>this toolbar is used on several screens</li> <li>the xaml of the toolbar is exactly the same over all those screens</li> </ul> <p>I want to remove the toolbar instance and replace it with a user control that provides 3 commands, so I can keep the bindings in each screen. The plan is to later change the toolbar functionality, but the external programming interface (namely, 3 commands) is the same. </p> <p>So: </p> <ul> <li>I created a user control, and created 3 sets of dependency properties for each command (OneCommand, OneCommandParameter, OneCommandTarget) so I can use these for the binding.</li> <li>I moved the toolbar xaml inside the user control xaml.</li> <li>I modified the bindings on the toolbar buttons to bind to the intristic user control properties</li> <li>on each screen (or really, only the first for now) I replaced the original toolbar with the user control,binding the new properties to the correct commands.</li> </ul> <p>The control shows, but the buttons don't work. That's about it. </p> <p>-- </p> <p>Original explanation - not so clear:</p> <p>I have a WPF user control encapsulating a number of buttons. Previously, the control was a Toolbar with a number of buttons on it, but since I need exact the same functionality on a number of screens, I refactored the toolbar into a custom control.</p> <p>However, I'd like to keep the command bindings of the original buttons. </p> <ul> <li>I created 3 sets of dependency properties (XCommand, XCommandParameter and XCommandTarget) on the usercontrol. </li> <li>In the user control xaml I bind the "real" buttons to those properties (each button to each set of properties). </li> <li>Where I use the usercontrol, I bind the new properties to the real command bindings.</li> </ul> <p>In essence, I want to keep the ICommandSource functionality for each "command" that the user control exposes. However, this dual databinding scenario doesn't seem to work, or I'm doing something wrong. :)</p> <p>Is there a better way to do this? All I need is to "bridge" the commands from outside the control to the inner buttons so the Execute and CanExecute functionality remains. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload