Daniel
Daniel

Reputation: 2004

Automatic gui generation in c#

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

Upvotes: 10

Views: 5473

Answers (5)

John Alexiou
John Alexiou

Reputation: 29244

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.

Upvotes: 2

Jay
Jay

Reputation: 625

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.

Upvotes: 3

Erwin J.
Erwin J.

Reputation: 617

We tried something like that in one of my previous projects but in the end it is just too restrictive and we went with hand built forms instead. Putting controls on forms doesn't take long anyway compared to coding the validation rules and presentation logic, both of which are a lot easier to code with regular forms.

Upvotes: 0

Andy Dent
Andy Dent

Reputation: 17969

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.

Upvotes: 1

Robert Harvey
Robert Harvey

Reputation: 180788

Something like this?

Using XML To Dynamically Generate GUI Elements
http://www.codeproject.com/KB/cs/aal-5a.aspx

Upvotes: 2

Related Questions