[英]Expose multiple command in WPF user control
A better explanation, I hope: 我希望有一个更好的解释:
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. 我想删除工具栏实例,并用提供3个命令的用户控件替换它,以便可以将绑定保留在每个屏幕中。 The plan is to later change the toolbar functionality, but the external programming interface (namely, 3 commands) is the same. 计划以后要更改工具栏的功能,但是外部编程接口(即3个命令)是相同的。
So: 所以:
The control shows, but the buttons don't work. 控件显示,但按钮不起作用。 That's about it. 就是这样
-- -
Original explanation - not so clear: 原始说明-不太清楚:
I have a WPF user control encapsulating a number of buttons. 我有一个WPF用户控件,其中封装了许多按钮。 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. 以前,该控件是一个带有许多按钮的工具栏,但是由于我需要在多个屏幕上使用完全相同的功能,因此我将工具栏重构为自定义控件。
However, I'd like to keep the command bindings of the original buttons. 但是,我想保留原始按钮的命令绑定。
In essence, I want to keep the ICommandSource functionality for each "command" that the user control exposes. 本质上,我想为用户控件公开的每个“命令”保留ICommandSource功能。 However, this dual databinding scenario doesn't seem to work, or I'm doing something wrong. 但是,这种双重数据绑定方案似乎不起作用,或者我做错了事。 :) :)
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. 我所需要的只是将命令从控件外部“桥接”到内部按钮,以便保留Execute和CanExecute功能。
I solved this. 我解决了 There was a bug in my RelativeSource in the internal control bindings. 我的RelativeSource中的内部控制绑定中有一个错误。 It works fine as expected, now. 现在,它可以按预期工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.