简体   繁体   中英

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?

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

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.

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

卡利本呢?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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