想知道如何最好地實現演示模型模式。我已經閱讀了MVVM,但不適用於我,因爲我沒有使用Silverlight或WPF。Winforms如何使用Presentation Model?
3
A
回答
0
Update Controls在Windows窗體中實現演示模型模式。您使用獨立字段編寫模型類。
public class Person
{
private Independent<string> _first = new Independent<string>();
private Independent<string> _last = new Independent<string>();
public string First
{
get { return _first; }
set { _first.Value = value; }
}
public string Last
{
get { return _last; }
set { _last.Value = value; }
}
}
然後,您編寫一個具有常規屬性的演示模型。
public class PersonPresentationModel
{
private Person _person;
public PersonPresentationModel(Person person)
{
_person = person;
}
public Person Person
{
get { return _person; }
}
public string FullName
{
get { return _person.Last + ", " + _person.First; }
}
}
處理Windows窗體控件中的事件以從演示文稿模型中獲取數據。
private string FirstName_GetText()
{
return _presentationModel.Person.First;
}
private void FirstName_SetText(string value)
{
_presentationModel.Person.First = value;
}
private string LastName_GetText()
{
return _presentationModel.Person.Last;
}
private void LastName_SetText(string value)
{
_presentationModel.Person.Last = value;
}
private string FullName_GetText()
{
return _presentationModel.FullName;
}
更新控件將在模型更改時跟蹤依賴關係並更新您的Windows窗體控件。它甚至可以通過演示模型來看看它依賴於什麼。
0
您可以通過MVP(模型視圖演示)被interrested,並依賴於它豐富的應用程序框架,如CAB(複合UI應用程序塊,從MS模式&實踐團隊)
使用MVP,你可以有演示模型並利用winform數據綁定。
Jeremy D. Miller blog是有關此設計和所有其他UI模式的信息的良好來源。
相關問題
- 1. 您如何在Webforms中使用Presentation Model?
- 2. 香菜依賴注入的問題,使用Presentation Model模式
- 3. 在代碼背後使用Presentation Model的主要缺點是什麼?
- 4. 我是否正確實施了MVP/Presentation Model UI模式?
- 5. 如何使用ng-model
- 6. 如何使用C#和WinForms
- 7. 如何使用CefSharp的WinForms
- 8. 如何實現這個想法?使用Controller,ServiceImple,Repository,Presentation
- 9. C#WinForms Model-View-Presenter(被動視圖)
- 10. WinForms中的RX和Model-View-Presenter
- 11. Windows Presentation Foundation中
- 12. 如何在Java中使用Model OOP
- 13. 如何使用bll,dal和model?
- 14. 如何正確使用Html.Raw(Json.Encode(Model))?
- 15. 如何在ng-repeat中使用ng-model
- 16. 如何使用render json:with active-model-serializers gem?
- 17. 如何在ember-model中使用belongsTo?
- 18. 如何在路線中使用`model`?
- 19. 如何從Model
- 20. Flex with Presentation模型
- 21. java EE6 JSF Presentation和Logic層如何互相協作?
- 22. c#winforms - 如何使DataGridViewRow UnSelectable?
- 23. C#的WinForms如何使用按鈕
- 24. 如何插入使用DataGridView - C#winforms?
- 25. Winforms:如何使用ToolStripDropDown模擬AutoClose
- 26. 如何在WinForms C#中使用線程?
- 27. 如何使用WinForms控制Windows服務
- 28. 如何在Winforms中使用foxtools.fll?
- 29. 如何開始使用WinForms的TDD
- 30. 在Windows Presentation Foundation中使用MVC代替MVVM