有关WPF设计模式的问题 [英] Question about WPF design patterns

查看:86
本文介绍了有关WPF设计模式的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

我几天前开始学习WPF,除了MV-VM之外,我在为该技术找到特殊模式时遇到了一些问题.请告诉我,可以使用哪种经典模式以及如何使用?

Hello

I started learning WPF few days ago, and i faced some problems with finding special patterns for that technology, except for MV-VM.Please tell me, which of classic patterns can be used and how?

推荐答案

任何一种设计模式或体系结构设计模式都可以实现:WPF非常灵活,并且对多种范例友好.

要在MVVM上获得一个不错的主意,请看以下示例:
解释了Model-View-ViewModel(MVVM) [ WPF:简化MVVM(模型视图视图模型) [ WPF第II部分中的MVVM [
Any of the design patterns or architectural design patterns can be implemented: WPF is extremely flexible and friendly to multiple paradigms.

To get a pretty good idea on MVVM, look, for example, here:
Model-View-ViewModel (MVVM) Explained[^],
WPF: MVVM (Model View View-Model) Simplified[^],
MVVM in WPF Part II[^].

Seach CodeProject for more information: there is a lot of interesting articles.
Please see my other Answer to the follow-up Question on State Machines.

—SA


我想为有关状态机的后续问题添加一个单独的答案.

仅为了说明状态机方法,请参阅我的文章
枚举类型不枚举!解决.NET和语言限制 [ ^ ],第3.6节笛卡尔广场".

状态机是可以用于分析的形式模型,但是在某些情况下,创建或多或少地将有限状态机(FSM)作为应用系统中的功能对象的通用模型非常有益.本质上,您有一组S元素,每个元素代表一个州.该集合的笛卡尔正方形的子集显示什么集合与什么相连.这是数学关系的定义,也可以用作任意有限图的表示形式之一.为了表示FSM,应该对图形进行定向,这在用代码实现笛卡尔正方形时总是一种情况.这样,Square的每个元素都说:此状态可以进入该状态". FSM上的计算自动化可以通过不使用布尔值表示元素来实现,而是使用某些数据项来承载有关如何进行过渡的重要信息(例如,用于驱动实际的机器人硬件),可以甚至一个委托实例.如果不允许过渡,则可以使用笛卡尔广场的元素来承载有关为什么不这样做的信息(错误消息或错误字符串的格式).

这样,我们就可以通过一种抽象的方法来处理由FSM模型通用描述的非常不同的行为.它与视图和表示"无关(无论是否具有WPF),因此FSM方法可以与MVVM或实际上专注于功能和UI分离的其他体系结构模式自由组合.
—SA
I want to add a separate Answer for the follow-up Question about the State Machines.

Just for illustration of a State Machine approach, please see my Article Enumeration Types do not Enumerate! Working around .NET and Language Limitations[^], section 3.6 "Cartesian Square".

A State Machine is a formal model which can be used for analysis, but in some cases it is very beneficial to create more or less universal model of a Finite State Machine (FSM) as a functional object in the application system. In essence, you have a set S of elements each representing a State. A subset of a Cartesian Square of the set shows what set is connected to what. This is a definition of mathematical Relationship and can also server as one of the representations of arbitrary finite graph. To represent a FSM, the graph should be directed, which is always a case when it comes to implementation of the Cartesian Square in code. In this way, each element of the Square says: "this state can go to that state". The automation of the calculation on the FSM can be done by representing the element not with Boolean values, but with some data items use to carry important information on how to make a transition (for example, for driving real robotic hardware), it can be even a delegate instance. If a transition is not allowed, the element of the Cartesian Square could be use to carry information on why not (error message or a format for error string).

In this way, we have an abstract approach to very different behavior universally described by a model of FSM. It does not have anything to do with Views and Presentation (WPF or not), thus FSM approaches can be freely combined with MVVM or other architectural patterns actually focusing on separation of functionality and UI.

—SA


这篇关于有关WPF设计模式的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆