Thursday, March 19, 2009

Changing the default Silverlight 3.0 menu to the AgMenu from DevExpress

As you all know, well maybe not all, that the new Silverlight 3.0 offers a new template called Silverlight Navigation Application, now this creates "Views" which are switched to and from using a default menu, and also supports the browser Back and Forward buttons.













But i didn't like the default Button menu provided, so i set out to use the AgMenu from DevExpress.

Now, digging into the Xaml, it's pretty simple, Add your namespace reference in the MainPage.xml file

    4 xmlns:dxm="clr-namespace:DevExpress.AgMenu;assembly=DevExpress.AgMenu.v9.1"


Add your menu xaml and overwrite the default Home & About buttons with

   13  x:Name="rootMenu" Height="28" VerticalAlignment="Top">

   14                         IsCheckable="False" x:Name="mnuUserName" Header="Home" Tag="/Views/HomePage.xaml" Click="mnuItems_Clicked"/>

   15                         IsCheckable="False" x:Name="mnuHome" Header="About" Tag="/Views/AboutPage.xaml" Click="mnuItems_Clicked" />

   16                    


Now all you need todo is wireup your Clicked events for the AgMenuItem's and you are done.

   32         private void mnuItems_Clicked(object sender, EventArgs e)  {

   33             String goToPage = (sender as AgMenuItem).Tag.ToString();

   34             this.Frame.Navigate(new Uri(goToPage, UriKind.Relative));

   35         }


And the finished Product


(SOLVED) AgDataGrid issues with SL 3.0

Currently, if you are using ColumsAutoWidth="True" and have not set a width for your Grid, SL 3.0 will throw a Layout Cycle Detected error.

So make sure you specify your Width!
Edit... well i take it back, seems it was a PEBCACK error there, just tried it on a different project different OS (now W7) and seems to be working, weird...

Silverlight 3.0 has been released!! (Well beta anyway)

If you are like me, and love Silverlight, then this article is for you!!


VS 2008 users, just download this, that is the Tools installer, which will install everything you require, also, if like animations, get this (Expression Blend 3.0), but don't try and open SL 2.0 apps in it, as they will automatically convert them to 3.0 and there is no going back.