It is easy enough to create a command from my OnLoaded() event handler code, but how do I call it from the View?
从OnLoaded()事件处理程序代码创建命令非常简单,但是如何从视图中调用它呢?
<window Loaded="onLoaded"> doesn't cut the cake anymore since it calls code in the xaml.cs. How would I create an ICommand equivalent?
2 个解决方案
#1
10
You can do this sort of thing via an attached behavior. To save yourself some time, take a looked at Marlon Grech's Attached Command Behavior library.
你可以通过附加行为来做这种事情。为了节省时间,我们来看看Marlon Grech的附加命令行为库。
#2
5
You could use the MVVM Light Toolkit's event to command behavior: http://blog.galasoft.ch/archive/2009/11/05/mvvm-light-toolkit-v3-alpha-2-eventtocommand-behavior.aspx
您可以使用MVVM Light Toolkit的事件来命令行为:http://blog.galasoft.ch/archive/2009/11/05/mvm - Light - Toolkit -v3- alpha2 - eventtobehavior.aspx
#1
10
You can do this sort of thing via an attached behavior. To save yourself some time, take a looked at Marlon Grech's Attached Command Behavior library.
你可以通过附加行为来做这种事情。为了节省时间,我们来看看Marlon Grech的附加命令行为库。
#2
5
You could use the MVVM Light Toolkit's event to command behavior: http://blog.galasoft.ch/archive/2009/11/05/mvvm-light-toolkit-v3-alpha-2-eventtocommand-behavior.aspx
您可以使用MVVM Light Toolkit的事件来命令行为:http://blog.galasoft.ch/archive/2009/11/05/mvm - Light - Toolkit -v3- alpha2 - eventtobehavior.aspx