tags:

views:

122

answers:

6

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

A: 

Something like this?

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

Robert Harvey
Yea something like that. I was using XML as an example, I'm not using it in my app at the moment but used as intermediate step this might be feasible.
Daniel
A: 

What is the complexity of the gui?you can use wpf. With the help of itemscontrol and data templates you can generate any type of gui.

Learn about WPF look less control. Obviously , you need some sort of metadata which tells you what sort of ui you want.

And wpf binding makes your life very easy when it comes to manage data through your ui.

We have recently developed this sort of application.

saurabh
Do you have an example?
Robert Harvey
It's my company's product, I can never post the source code but I can write some sort of example. I will post that example today.
saurabh
A: 

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.

Andy Dent
A: 

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.

Erwin J.
+1  A: 

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.

Jay
A: 

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.

jalexiou