简体   繁体   English

WPF中有C#的MVC模式吗

[英]Is there a MVC pattern for C# in WPF

Is there a pattern where in WPF, I can build a simple UI form from an XML like definition file pulled from a database? 在WPF中,是否有一种模式可以通过从数据库中提取的XML(如定义文件)构建简单的UI表单?

It would allow the user to enter data into this form, and submit it back. 它将允许用户将数据输入此表单,然后提交回去。 The data would be sent back in an XML structure that would closely/exactly mimic the UI definition. 数据将以XML结构发送回,该结构将精确/精确地模仿UI定义。

The definition should include the data-type, and if it was a required value or not. 该定义应包括数据类型,以及是否为必需值。 I would then like to map these data-types and required values to Data Validation Rules, so the form could not be submitted unless it passes the check. 然后,我想将这些数据类型和所需的值映射到“数据验证规则”,因此除非表单通过检查,否则无法提交该表单。

It should also handle the ability to have lists of repeating data. 它还应具有具有重复数据列表的功能。

I am in the planning stages of this project and have fairly good flexibility in the design at this point, though I am pretty sure I need to stick to the desktop, not web since I may be doing some Office Inter-op stuff as well. 我现在处于该项目的规划阶段,并且在设计时具有相当好的灵活性,尽管我可以确定我需要坚持使用台式机而不是Web,因为我可能还会做一些Office Inter-op的工作。

What technology stack would you recommend? 您会推荐什么技术堆栈? I think XMAL and WPF may be close to the answer. 我认为XMAL和WPF可能接近答案。

I have also looked at XUL , but it doesn't seem ready or useful for C#. 我也看过XUL ,但是对于C#来说似乎还没有准备好或有用。 (Found this article from MSDN in 2002) (在2002年从MSDN找到这篇文章

Thank you, 谢谢,
Keith 基思

Model View Presenter seems to suit WPF quite well, if you've not heard of it before check out the Supervisor Controller pattern, which is a subset of MVP (the author has renamed it to Supervisor Controller and Passive View as two different flavours of MVP). Model View Presenter似乎非常适合WPF,如果您在签出Supervisor Controller模式之前没有听说过它,它是MVP的子集(作者已将其重命名为Supervisor ControllerPassive View,作为MVP的两种不同形式) )。 It is a design principal that will help you promote the separation of concerns and works much better than MVC when you don't have a framework to physically enforce it. 它是一种设计原则,可以帮助您促进关注点的分离,并且当您没有物理上强制执行的框架时,它比MVC更好。

You could always try to create a view engine for ASP.NET MVC that works with WPF though, that would be nice. 您始终可以尝试为ASP.NET MVC创建一个与WPF一起使用的视图引擎,这很好。

Well if you wanted to roll something yourself, you can load and render dynamic XAML pretty easily. 好吧,如果您想自己滚动一些东西,则可以非常轻松地加载和呈现动态XAML。 Rather than have users create XAML directly you could have a subset of it "mapped" to an XML format of your choosing that you XSL into valid XAML: 与其让用户直接创建XAML,不如让您将XSL转换为有效的XAML的方式将其子集“映射”为XML格式:

XmlReader tXml = XmlReader.Create(myXamlString);
UIElement MyElement = (UIElement)XamlReader.Load(tXml);

卡利本呢?

You might want to consider taking a look at the CSLA.NET framework. 您可能需要考虑看看CSLA.NET框架。 You can read about it here along with info on a well written book that's available: 您可以在这里阅读有关它以及一本可用的书本上的信息:

http://www.lhotka.net/Default.aspx http://www.lhotka.net/Default.aspx

-Eric -Eric

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM