开发者

CommandManager "cannot resolve symbol"

开发者 https://www.devze.com 2022-12-31 06:34 出处:网络
After adding \"RelayCommand\" class (that uses CommandManager class) into my Silverlight App I\'ve got an error:

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号