CommandManager "cannot resolve symbol"
After adding "RelayCommand" class (that uses CommandManager class) into my Silverlight App I've got an error:
The name 'CommandManager' does not exist in the current context
This class is a member of System.Windows.Input namespace that is in PresentationCore.dll assembly. The problem is that I can't add this dll into my app...
I am having a strange assumption: this class (CommmandManager) can't be used in the Silverlight. Am I right?
How can I implement MVVM-pattern (http:开发者_开发百科//msdn.microsoft.com/en-us/magazine/dd419663.aspx)?
Thanks.
You can use MVVM Light framework, that provides a Silverlight version of RelayCommand
.
Silverlight has very primitive support for ICommand. In particular it does not support command routing or the CommandManager. It doesn't even provide an implementation of ICommand. It just defines the interface and ButtonBase knows how to use it.
So bottom line is, you need to remove that WPF-specific part of the code or create some kind of basic implementation of CommandManager in Silverlight.
Indeed the CommandManager class does not exist in SilverLight... Check the following blog post for a solution in SilverLight:
http://blog.walteralmeida.com/2010/06/modelviewviewmodel-design-pattern-an-implementation-of-relaycommand-for-silverlight.html
精彩评论