Finally, the facts are out for
I’ve been waiting for this release for a few years now. Prior to this
it has all been roumors and speculation.
First impressions: Very Mixed
The first things that struck me was how MS reinvented everything. A lot of
your exisitng experience for writing applications are totally wasted, at least if
you come from a web background. This is beacuse even though XAML is said to be an
XML language it does not support any other
W3C technology. No
CSS. XAML is just not using an
XML rendering engine as I first
hoped. It is just a serialization model for WinFX applications.
On the other hand I think the reason for not using the W3C DOM is that it
makes the object model XAML uses more friendly to WinForms programmers. The
object model is also type safe, which is a good thing This has however a
serious downside. You need to know 2 different APIs, one for the XML format and
one for the object model. Even if you know how the attribute works you may not
know how the property works. Below are 2 examples that shows examples of this.
<XAML> <Button ID="foo">Hello World</Button> foo.Content = "Changed"; </XAML> <XUL> <button id="foo" label="Hello World"/> document.getElementById("foo").setAttribute("label", "Changed"); </XUL>
<XAML> <Text FontSize="12pt" Background="White">Hello World</Text> el.FontSize = new FontSize(13, FontSizeType.Point); el.Background = Brushes.Red; </XAML> <XUL> <label label="Hello World" style="font-size: 12pt; background: white;"/> el.style.fontSize = "13pt"; el.style.background = "red"; </XUL>
A small comment here: XUL
has bugs preventing DOM Style to work but that does not change the scenario.
The main problem with XAML is that one cannot use W3C DOM. I don’t know why
this decision was made. It can’t be hard because WinFX already knows how to do
the type conversions.
One thing that I do like about this is that it is tightly bound to the WinFX
API. An element directly maps to a class, in fact any class that has a
constructor without any arguments can be an element. All properties of the class
maps to a attributes of the element (how does the type conversion work?) and
finally all events also map to attributes. This model is way more conventient
and useful than both the XBL and behavior solution for extending the markup.
Another nice thing is that properties of the class can actually be declared
as child nodes of the element. This allows more complex attributes to be used.
<Button> Hello World <Button.Background> <LinearGradientBrush > <LinearGradientBrush.GradientStops> <GradientStopCollection> <GradientStop Color="Red" Offset="0" /> <GradientStop Color="Blue" Offset="0.25"/> <GradientStop Color="Orange" Offset="0.75"/> <GradientStop Color="Yellow" Offset="1"/> </GradientStopCollection> </LinearGradientBrush.GradientStops> </LinearGradientBrush> </Button.Background> </Button>
Finally I wanted to mention something called style. Styles are note like W3C
Stylesheets, one of the best technologies MS has been pushing (was pushing).
Styles are more like templates. The thing that I like about them in favor of CSS
is that any attribute can be set. The thing that I don’t like about them is the
C of CSS and that is that the do not really cascade and the selectors seems just
way too simple. Just give me the CSS3 selectors will yah?
<Style> <VerticalSlider Width="50%" Margin="25%,0,25%,0" Minimum="0" Maximum="255" SmallChange="1" LargeChange="16" DockPanel.Dock="Fill"/> </Style>
Just when I thought I was finished I realized one more thing. I wish they
will add the XUL box model to this as well. Although XAML seems fairly nice when
it comes to writing UIs that scale it seems that the XUL box model is more
consistent. I hope someone/they adds box, hbox, vbox (with flex and all the
other goodies) before the API is finalized.