WPF RibbonControl 命令
我刚刚开始使用 Microsoft 的 WPF RibbonControl 库(2010 年 10 月版本)。看来 ICommand 实现现已可用,并取代了 RibbonCommand 作为更 MVVM 友好的实现。
但是,我无法将 viewmodel 命令(在我的例子中作为 prism DelegateCommand)数据绑定到视图,就像我对标准按钮所做的那样。
这基本上是我正在寻找的内容:
在 ViewModel 中:
public ICommand NavigateCommand { get { return new DelegateCommand<String>(NavigateExecute); } }
void NavigateExecute(String param)
{
// do whatever you want
}
在 XAML 中:
<ribbon:RibbonButton Command="{Binding NavigateCommand}" CommandParameter="1"/>
但是该命令从未被触发。任何提示都将受到欢迎。
I just started playing around with the WPF RibbonControl library from Microsoft (October 2010 release). It seems that an ICommand implementation is now available and replaces the RibbonCommand as a more MVVM friendly implementation.
However, I haven't been able to databind the viewmodel command (as a prism DelegateCommand in my case) to the view, as I would do for standard buttons.
Here is basically what I'm looking for :
In the ViewModel :
public ICommand NavigateCommand { get { return new DelegateCommand<String>(NavigateExecute); } }
void NavigateExecute(String param)
{
// do whatever you want
}
In XAML :
<ribbon:RibbonButton Command="{Binding NavigateCommand}" CommandParameter="1"/>
The command is however never triggered. Any hint would be most welcome.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道这是否对您的情况有帮助,但在我移动到新版本功能区后,我将所有 ICommand 属性设置为静态并且有效。当然,这意味着您的命令方法也必须是静态的。
尝试一下并告诉我们。
I don't if this will help in your case, but after I moved to the new release ribbon I made all ICommand properties static and that worked. Of course this means your command methods have to be static also.
Give it a try and let us know.