views:

222

answers:

2

How would you go about making an application that can edit it's own look and feel? Can tweak its own XAML files? then reload them. I'm thinking a notepad-like text editor, not a visual designer.

All the event/code would be bound right after display from an "iron" scripting language.

+5  A: 

You can do this anyway you want, just completely abstract the display engine from all other logic including event bindings and what not. The data-format for the UI be it XAML or even an executed JavaScript blob then doesn't matter.. what matters is the engine can provide a consistent interface for passing events back to the logic, regardless of the UI state.

To do this you could create a self modifying engine that uses an engine definition to construct an engine for self-modifying UI definitions :P

Aiden Bell
+1 for the awesome quote in the second paragraph. :)
Andy
+1 Cool. I think I will call my new engine Skynet.
tyndall
How about if you just had XAML in the database that was more like a document (rather than a true GUI interface). How does the WPF engine display XAML in XAML? What control or mechanism?
tyndall
XAML in XAML ...? XAML into an engine that can reload the XAML definition, display the UI it defines and re-hookup the events and stuff.
Aiden Bell
+1  A: 

I have written a few prototypes where I put a XAML document on a web server and download that XAML and load it into an ElementHost control on a WinForm form. It worked quite well.

I have not tried hooking up event handlers yet though.

Update: This blog post by Rob Relyea has more information that you could ever want to know about hooking up events to downloaded XAML.

Darrel Miller
I would recommend some kind of abstraction of events and handlers such that the logic side maintains a hashtable of virtual events and handlers that the UI can bridge to.
Aiden Bell
Cool ideas guys. +1
tyndall