Sam asks "the
ability to modify the rendering and content of the document on the fly? Isn't
that lost by a compile to bytecode approach?"...
Sorry for the delay in responding, Sam's post has been sitting in my inbox while I
found a couple minutes to respond... There are lots of comments on Sam's post directly
that respond to this, but I thought a more detailed answer might prove interesting
for everyone...
First, as people pointed out there is a difference between XAML (the programming model)
and Avalon (the presentation system).
Using XAML, you can invoke the parser at anytime:
DockPanel d = (DockPanel)Parser.LoadXML("<DockPanel
xmlns=\"http://schemas.microsoft.com/2003/xaml\"><Button DockPanel.Dock=\"Fill\">Hello</Button></DockPanel>");
(Appologies if the code doesn't compile, i'm not sitting in front of a Longhorn
machine right now)
However - that XAML can't contain any def:Code fragments, because at this time we
don't do dynamic compilation on the client during parsing.
In addition to dynamic execution of the compiler, you can also programmatically create
elements:
DockPanel panel = new DockPanel();
Button b = new Button();
panel.SetDock(b, Dock.Fill);
b.Content = "Hello";
panel.Children.Add(b);
Of course, you can also set events:
b.Click += new ClickEventHandler(MyHandler);
In fact, the parser is really just doing a bunch of "new DockPanel" and "new Button"
calls when it parses the XAML. XAML is just another view on code... You can do everything
in code that you can do in XAML - and you can do it dynamically with a strongly typed
simple programming model.