WPF 中 C# 是否有 MVC 模式

发布于 2024-07-11 01:37:16 字数 637 浏览 10 评论 0原文

在 WPF 中是否有一种模式,我可以从从数据库中提取的类似 XML 的定义文件构建一个简单的 UI 表单?

它将允许用户在该表单中输入数据并将其提交回来。 数据将以 XML 结构发回,该结构将紧密/精确地模仿 UI 定义。

定义应包括数据类型,以及它是否是必需的值。 然后,我想将这些数据类型和所需值映射到数据验证规则,因此除非通过检查,否则无法提交表单。

它还应该能够处理重复数据列表的能力。

我正处于这个项目的规划阶段,目前在设计上有相当好的灵活性,尽管我很确定我需要坚持使用桌面,而不是网络,因为我可能也在做一些 Office Inter-op 的东西。

您会推荐什么技术堆栈? 我认为 XMAL 和 WPF 可能接近答案。

我还查看了 XUL,但它似乎对 C# 还没有准备好或没有用处。 (2002 年从 MSDN 找到这篇文章

谢谢,
基思

Is there a pattern where in WPF, I can build a simple UI form from an XML like definition file pulled from a database?

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.

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.

What technology stack would you recommend? I think XMAL and WPF may be close to the answer.

I have also looked at XUL, but it doesn't seem ready or useful for C#. (Found this article from MSDN in 2002)

Thank you,
Keith

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

醉生梦死 2024-07-18 01:37:17

Model View Presenter 似乎非常适合 WPF,如果您在查看 Supervisor Controller 之前还没有听说过它 模式,它是 MVP 的子集(作者已将其重命名为 Supervisor Controller被动视图 作为两种不同风格的 MVP)。 它是一个设计原则,可以帮助您促进关注点分离,并且当您没有框架来实际执行它时,它比 MVC 效果更好。

不过,您始终可以尝试为 ASP.NET MVC 创建一个与 WPF 一起使用的视图引擎,那就太好了。

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). 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.

You could always try to create a view engine for ASP.NET MVC that works with WPF though, that would be nice.

尐籹人 2024-07-18 01:37:17

如果您想自己开发一些东西,您可以非常轻松地加载和渲染动态 XAML。 您可以将其子集“映射”到您选择的 XML 格式,然后将 XSL 转换为有效的 XAML,而不是让用户直接创建 XAML:

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

Well if you wanted to roll something yourself, you can load and render dynamic XAML pretty easily. 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:

XmlReader tXml = XmlReader.Create(myXamlString);
UIElement MyElement = (UIElement)XamlReader.Load(tXml);
椒妓 2024-07-18 01:37:17

您可能需要考虑查看 CSLA.NET 框架。 您可以在这里阅读相关内容以及一本写得很好的书的信息:

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

-埃里克

You might want to consider taking a look at the CSLA.NET framework. You can read about it here along with info on a well written book that's available:

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

-Eric

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文