Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 10 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(7)
MVVM Light 也是一个很好的解决方案,并且它有一个非常容易找到的基类:-)
MVVM Light is also a good solution, and it has a really easy to find base class :-)
我认为 MVVM 的基本原理非常简单,因此重新发明轮子会更容易。您需要的所有基本功能是该类实现
INotifyPropertyChanged
(基类可以具有OnPropertyChanged(string propertyName)
的标准样式实现)。除此之外,还有RelayCommand
或类似的 - 只是一个在Execute
中执行委托的ICommand
实现。总而言之,只有几行代码,而且非常整洁。您还在寻找什么其他功能?如果它要处理底层 BDO(例如
DataRow
、XmlNode
或 POCO),那么它实际上不应该位于 VM 基类中,而应该位于派生类中。希望有帮助。
I would suggest that the basic principles of MVVM are so simple that it would be easier to reinvent the wheel. All the basic functionality you need is for the class to implement
INotifyPropertyChanged
(the base class could have the standard-style implementation ofOnPropertyChanged(string propertyName)
). Beyond that there's theRelayCommand
or similar - just anICommand
implementation that executes a delegate inExecute
.All-in-all, just a few lines of code, and it keeps it very neat. What other functionality are you looking for? If it's to deal with the underlying BDO (say a
DataRow
,XmlNode
or POCO) then it shouldn't really be in the VM base class, but a derived class.Hope that helps.
WPF 应用程序框架 (WAF) 是开源的,包含 ViewModel 基类 (用于实现模型-视图-视图模型模式)。
The WPF Application Framework (WAF) is open source and contains a ViewModel base class (for implementing the Model-View-ViewModel pattern).
微软Prism。完全访问源代码。学习曲线有点陡峭,但一旦掌握了它,它就会非常有效。
Microsoft Prism. Full access to the source code. A bit of a steep learning curve but once you get a handle of it, it works really well.
查看 Nikhail Kothari 的博客,了解他的 SilverlightFX 库,它是一个开源 MVVM,您可能会发现有用。
Check out Nikhail Kothari's blog for his SilverlightFX library, its an open source MVVM u might find useful.
SoapBox Core 是一个开源 (LGPL) MVVM(和 MEF)框架,用于构建可扩展的 MVVM 应用程序。类层次结构包括一个基本 ViewModel 类(以及与此相关的接口)。
SoapBox Core is an open source (LGPL) MVVM (and MEF) framework for building extensible MVVM applications. The class hierarchy includes a base ViewModel class (and interface for that matter).
这是我的一个例子......它不会真正帮助你,因为我想要我的视图模型做的事情会与你想要你的视图模型做的事情不同......但也许它会给你一个开始。基类的问题是,如果你把它放在你的核心中......你只需要写一次......
Here is an example of mine...it wont really help you, because want I want my viewmodels to do will be different then what you want your viewmodels to do...but maybe it will give you a start. And the thing with the base class is if you stick it in your Core...you only have to write it once...