问题
is it possible to create winforms based on an xsd file and xml ? maybe by using something similar to xslt (webforms)?
回答1:
I don't think, because web forms are basically HTML or Text files, so we can render using XML / XSLT. But in the case of WinForm, it is different and complex. Yes you can try around XML Serialize / Deserialization concepts. Or XAML in WPF.
回答2:
Sounds like you want to create editors for dataset objects dynamically. If you take a look at the designer.cs file of a winform you'll notice that the form is actually created by creatign the controls and then setting their properties programatically. If this is what you want to do at runtime then you can use the structure of the XSD to create the controls and populate the form.
Can I ask what the purpose of this is? Sounds intersting.
回答3:
I've seen people experiment with using the XAML parsing/loading for creating WinForms controls. Here's an old post I stumbled across: http://anoriginalidea.wordpress.com/2007/12/13/weird-science-defining-winforms-in-xaml/
And there has been a similar question asked at: Using XAML in WinForms.
Beyond that, I haven't see a robust or complete approach, but that's not to say it isn't possible.
回答4:
A few month ago I create an application which Converts an XSD file in to an Xml sample then Generates a form based on the file.
来源:https://stackoverflow.com/questions/5334235/create-winform-from-xsd-xml