我很喜歡mvc,mvp或mvvm模式。所以我正在尋找谷歌爲勝利表單應用程序實施良好的設計模式。我發現很多article.few傢伙說mvc是好的,很少有人說mvp是勝利應用的完美選擇。我發現了一個非常小的代碼,它在win apps中實現了mvp。我瀏覽代碼並發現開發人員必須編寫大量額外的代碼來綁定treeview或任何控件。windows窗體&設計圖案
如下
public interface IYourView
{
void BindTree(Model model);
}
public class YourView : System.Windows.Forms, IYourView
{
private Presenter presenter;
public YourView()
{
presenter = new YourPresenter(this);
}
public override OnLoad()
{
presenter.OnLoad();
}
public void BindTree(Model model)
{
// Binding logic goes here....
}
}
public class YourPresenter
{
private IYourView view;
public YourPresenter(IYourView view)
{
this.view = view;
}
public void OnLoad()
{
// Get data from service.... or whatever soruce
Model model = service.GetData(...);
view.BindTree(model);
}
}
請人通過代碼,並幫助我瞭解流量,因爲如何代碼應在MVP的圖案,我不知道寫的代碼。謝謝。
請重新格式化 - 不要使用'...',但插入4個空格前的每代碼行 – dantuch 2011-03-21 18:16:18
我最近一直在學習winforms模式,並想了解,但我不能放棄理解你的問題... – 2011-03-21 18:17:41