c# - MVVM 的通用接口(interface)

标签 c# mvvm interface

嗨,有人可以告诉我我是否错过了一些有用的界面吗?还有缺点吗?

对于模型:

  • IEditableObject
  • IClonable
  • INotifyPropertyChangingINotifyPropertyChanged(如果后端有一些模型更新)
  • ???

对于 ViewModel:

  • INotifyPropertyChanging
  • INotifyPropertyChanged
  • IDataErrorInfo
  • IDisposable
  • ???

对于 View :

  • >??? (我听说过IView (DataContext {set;}))

最佳答案

是的,您拥有框架本身提供的所有通用接口(interface)。这些应该足以让您成为 MVVM 忍者!

如果您需要其他任何东西,我建议您在需要时创建自己的界面。

关于一般接口(interface),请参阅我回答的相关问题:

I'm worried I'm adding too many interfaces

If I create an IView interface, will I ever reference my class by that interface alone? i.e. will there be contexts where I interact with my class purely via the single property that interface exposes?

Also, can you consider contexts where you will interact with multiple implementation of this IView interface?

If the answer to both of these question is "no", then the interface serves very little purpose.

关于c# - MVVM 的通用接口(interface),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14931463/

相关文章:

c# - MVVM? mvvmc?还是我做错了?

c# - 在 C# 中的 IAsyncEnumerable 线程安全中增加一个整数吗?

c# - 获取 WPF Treeview 的 SelectedItem

wpf - 一起使用 F# 和 Caliburn.Micro

go - 在 golang 中模拟内部函数

java - 覆盖接口(interface)的变量?

c# - 在 C# UWP 应用程序中的何处粘贴 API 调用

c# - Silverlight DataGrid 中的选定项

c# - 我可以使用 C# 禁用表单的 'close' 按钮吗?

c# - 迁移到 AutoMapper 5