Is there any library or automatic way to generate a GUI in C# from an arbitrary structure?
For example if I have a class hierarchy I can express it in XML by adding attributes like [XmlAttribute("depth")]
or [XmlElement("node")]
and passing it to an XML serializer. Can I used different annotations then send it to some GUI construction class to get a form built?
As another example for those who have used BlueJ for java, it provides access to classes and their members in a gui environment (though it has access to the source).
This is why XAML exists. XAML is an XML Markup Language for GUIs and it's parsed by the XAML Parser into UI objects like Window, Button, Image, etc.
XAML is the XML GUI syntax used by WPF (Windows Presentation Foundation) and Silverlight.
Something like this?
Using XML To Dynamically Generate GUI Elements
http://www.codeproject.com/KB/cs/aal-5a.aspx
It is crude, but sometimes it does it's job. Use a PropertyGrid
to view/edit up your classes. So you go from XML to classes via serialization and the view in a form using a property grid.
I haven't used it bit there's a port of Naked Objects for .Net, written about in this InfoQ article and in this podcast. I think that's the best match for what you're talking about. I've written my own code generator to create XAML and C# from an XML spec but I think you want a dynamic solution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With