开发者

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 i开发者_开发问答n 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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜