I read Chris Sell’s blog and found out that the new Avalon CTP is available to public. As a member of the public I was too excited and decided to download and play with the CTP, CLR beta 2 and Visual C# Express. I was a bit worried as I have all kinds of VS installations, Avalon and CLR bits on my laptop. Following the advice from the download page, I managed to get everything working together very quick [be sure to do some reboots].

 

I need to dev something with it so I decided to revive my NNTP dude sample which definitely won’t work with current build (when I compiled the project I got almost ½ the source code lines giving error) and needed to screen redo. If you have looked at the source code before, it is all done programmatically in C#, nothing fancy.

 

I decided to only use my old Nntp library and redo all the UI with XAML. The original Avalon part of source code is 1124 lines. With my new code I am getting more with:

 

118 lines of XAML

250 lines of C# code for partial class event handling and init.

 

Wow, that’s a lot of reduction. Definitely increase productivity and making my whole UI more flexible to change. I can’t imagine changing some of my view in the old C# code but now I’ve already change a view Visual Styling and all done declaratively.

 

New NNTP dude Screenshot
 

I still like 2d vector graphics as you can see. I am learning 3d elements and hopefully can utilize them next time. I felt that 3d is only for presentation like charting and special transitions [this is my personal opinion]. 

The one problem I faced with all these downloads (VC# express) is that it cannot start a Avalon/XAML project [maybe just me :-(]. What I did is to download a cool AvPad sample from ChrisAn’s SimpleGeek site [downloading this source code is highly recommended, be sure to look at his MyApp.xaml] and modify that csproj and get it launched with VC# express. This samples I got there comes with some very exciting styles and I reuse some of them. Also, this project is my reference to some new XAML syntax.

 

With just 10-12 hours (the last time was 3-4 days), I managed to get my Nntp app revived (with all XAML syntax). I did use some GDI calls to make my app look as like Windows Media Player (custom geometry clipping).

 

internal static void MakeIrregularWindow(Window win)

{

WindowInteropHelper interopWin = new WindowInteropHelper(win);

int handleRegion = CreateRoundRectRgn(0, 0,    

                     AppWidth,AppHeight,AppRadius,AppRadius);

SetWindowRgn(interopWin.Handle, handleRegion, true);

}

 

Don’t get me wrong, I like default Windows Styles/Themes. Just that I want to expose more of Avalon flexibility and Styling capabilities in my sample App.

 

Most of my Xaml code goes to defining the layout and having some custom ItemStyle and VisualTree to make things look good. Setting ItemsSource in event handlers. I did have an inline Master-Detail list which I define a ListBox having another ListBox in the VisualTree – which I thought is cool.

 

I really like to share my project files but I can’t do that as I don’t have external website to host a .zip file [any recommendation?]. I am use MSN Spaces to store my screen shot image.

I might blog more and dissecting the XAML in my sample and explaining my findings when I have time next week.

 

- Kenny


Content is provided "AS IS" with no warranties, and confers no rights.