Avalon lon way to get it - XAML, Xml and (not) Xslt
First, apologies for the title. They made me do it!
So I am finally managing to find some spare time to have a look into Avalon, Indigo and Winfx. However, my first look at Avalon and how it uses Xml is both exciting and confusing all at the same time. Aplogies for any mix up in the various names - still getting used to them.
The way the code separation is done is very cool - i like being able to separate logic from layout from styling. Heck been doing it for years with Xslt, but Avalon makes it even better :)
Maybe this last sentence makes it obvious where the confusion lies. Now, can i re-iteterate I am just looking into this stuff (spent most of my time on Whidbey) so please, please, please don't call my mum (mom) and tell her her son sucks (at least not for this blog) - this is first impressions.
So, Xslt. I like it. It's easy, it works and it is part of the Xml family that I was introduced to way back pre-1998. However, what i seem to see in Avalon is some new technique being adopted to basically do the same thing and I can't quite understand why.
So an example in Avalon using Xaml may be:
<FlowPanel ID="fp">
<FlowPanel.DataContext>
<Bind DataSource="{Contacts}" />
</FlowPanel.DataContext>
<Button Click="PickIt">Get Them</Button>
<ListBox ItemStyle="{Person}" ID="_result">
<ListBox.Items>
<CollectionContainer Collection="*Bind(Path=/Contacts/*)" />
<ListBox.Items>
</ListBox>
</FlowPanel>
In Xslt you could simply do :
<FlowPanel ID="fp" xmlns:dsExt="urn:microsft-com-avalon">
<FlowPanel.DataContext DataSource="dsExt:Bind(Contacts)" />
<Button Click="PickIt">Get Them</Button>
<ListBox ItemStyle="{Person}" ID="_result" Collection="dsExt:Bind(/Contacts/)" />
</FlowPanel>
Again, in Avalon you may have :
<Style def:Name="Person">
<ListItem />
<Style.VisualTree>
<FlowPanel>
<Border Margin="3" BorderBrush="Blue" BorderThickness="1pt">
<SimpleText Text="Bind(Path=DisplayName)" />
</Border>
<Border Margin="3" BorderBrush="Orange" BorderThickness="5pt">
<SimpleText FontStyle="Italic" Text="Bind(Path=Email)" />
</Border>
</Style.VisualTree>
</Style>
In Xslt you may have (but would never explicity put style in like this - i got CSS) :
<Style def:Name="Person">
<ListItem />
<Style.VisualTree>
<FlowPanel>
<Border Class="BorderStyle1">
<SimpleText Text="dsExt:Bind(DisplayName)" />
</Border>
<Border Class="BorderStyle2">
<SimpleText Class="Italics" Text="dsExt:Bind(Email)" />
</Border>
</Style.VisualTree>
</Style>
Things like <Style.VisualTree> concern me, but i may be missing the point. For me it's Xml is data, Xslt is layout and Css is style (sure you can put style in Xslt, but why?). On top of that you already have Xml schema that works well with Xml and Xslt. Beyond this you could even write an Xml Schema that could derive the components on the page, leaving thing like text to the Xml and style and positioning to the Xslt. I already do all this on a current project to derive ASP.Net pages. However, in here i see all of this in together. We see Path, when XPath is an implicit part of Xslt. Even extension functions can make the more complex stuff easy too.
Any if you say this is easier than Xslt then i'd love to know how? For me they are very similar and in fact Xslt may even be easier. Show me something hard to write in Xslt that is easy in Avalon.
One disclaimer I will add is that Microsoft always bring out the coolest technology that suddenly makes sense - certainly everything else I have seen if definitely what i was wanting and there is even some stuff in there i didn't know i wanted. So i aint being old miserable me, just fishing for answers!
vtgo.net