New Live Presentation Series – Starts 6/25

This schedule was modified on July 4. The schedule will be kept up to date by a notice in the side bar under presentations which will link to a dedicated page outside the blog.

 

 I am pleased to announce a new series, blending Conference-quality presentations delivered through Live Meeting via the Live From Redmond Series.

Audience, Goal and Purpose

Each presentation will provide a thorough overview of a Silverlight 2 topic with a focused  priority of explaining

  • What is this feature and why do you care?
  • What are the most important things you need to know?
  • Where can you learn more?

Every presentation will be paired with a blog entry containing links to videos, tutorials, and other resources to complement the material presented. The tutorials and videos will focus on how, but the Presentation will focus on What and Why.

While there will be quite a bit of code shown, these are not “How Do I” presentations but rather “What do I need to know and why do I care?” presentations.

Each presentations will be provided through Microsoft Webcasts in the “Live From Redmond” series and will be recorded for download after processing.

 

Each presentation is free but you will need to register in advance.  You will also need Microsoft Live Meeting Software to view the presentation (learn more here).

Posted in z Silverlight Archives | Comments Off on New Live Presentation Series – Starts 6/25

Who Ate My Mouse Down Event??

Before I leave, I want to squeeze in one quick note about a problem a lot of folks are running into as they upgrade from Beta 1 to Beta 2. I’ll come back to this in more detail when I get back, but here it is in a nutshell.

A breaking change in the Beta 2 upgrade is that all the controls now handle MouseLeftButtonDown/Up/Move, while graphic objects do not.

That means that no built in control will pass those events on (bubble them up) anymore. So, if you revisit my example for drag and drop what you’ll find is that if you create a button that has a graphic object inside it, and you drag on the button, it will not move, but if you drag on the graphic object it will! 

VLGMButton

You can see this in (the newly updated) Tutorial #1 (where the image for Drag and Drop is misleading). Dragging on the Very Little Green Man works, dragging on the button he is in, does not.

That is because the Very Little Green Man consists of nothing but Graphics (elipses and paths) but the button is a control and the control eats the event.

This is why figure 1.9 in the tutorial has to be replaced; you can’t drag the button, you have to drag the green man,

BrokenImage
Broken image

It’s subtle but important, where the mouse is shown, you could not be dragging. Yes, in Beta 1, no in Beta 2.

FixedImage
Fixed image

Here the mouse is dragging the little green man, and that will work just fine.

The full reason for this is to come, but the short explanation is that this helps controls in Silverlight behave more like controls in WPF.

Posted in z Silverlight Archives | Comments Off on Who Ate My Mouse Down Event??

Silverlight Geek Gone Fishing

vacation

 

 

I will be away for a few days. Please leave packages outside my blog, and someone feed the cat.  

 

 

 

 

Thanks.

Posted in z Silverlight Archives | Comments Off on Silverlight Geek Gone Fishing

Boston .NET Users Group Meeting

 

Last night I had the opportunity to talk to a packed room at the Boston .NET User’s Group; an incredibly welcoming and most friendly group of some 150,000 screaming fans of all things Microsoft.

I promised at the time to provide a few links; including of course the single most important; the link to Silverligh.net, as well as a link to my blog, to  our Getting Started page, a link to the videos and a link to the tutorials.

Other important resources mentioned were Scott Guthrie’s blog,  Tim Heuer’s Blog and  Silverlight Cream.

You can subscribe to the Silverlight Microblog here, though it will be fairly quiet for the next week or so.

Thanks again for coming, for your questions, for the car and for your kind words.

 

Presentation Slides

-j

Posted in z Silverlight Archives | Comments Off on Boston .NET Users Group Meeting

O’Hare is a Very Big Place

I got to O’Hare at 1pm because the hotel I was staying at had the usual early check out time and it being Sunday there was no reasonable place to go.  When I got here I learned that my 6pm flight was delayed to 10pm. I won’t bore you with the details but after a few hours I decided some food was in order and so stopped at a grill and sat down next to a total stranger who turned out to have just moved here from a part of Brooklyn not far from where I grew up.

Being relentlessly intrusive, I threw matches on the conversation until it flared, and soon we were talking about this year’s election and not long after that we were deep into racism (he is black, I am not).

This can be a difficult conversation, as I’m sure you know but apparently we were  both into it, and we really got into the nitty-gritty.   Why am I telling you this? Because at the end we exchanged biz cards so that we could exchange celebratory emails on election night and it was then that I discovered that he is the creative director for web development for  a major network who happens to be very interested in learning more about Silverlight.

Zow!  This was quite cool.

Ohare

So many laptops, so few outlets

Also I wanted to ask why an airport as big as O’Hare has so few chairs near outlets, and why there was a stretch of hallway where I saw 7 people, apparently unrelated and not with each other, all working on Mac laptops, followed immediately by about 12 others working on PCs?  Is this some sort of sociology experiment?

I finally popped for $50 to work in the “Admiral’s club” of one of the airlines where they offer two wonderful alternatives: tiny cubes with not enough light or outlets or nice big tables that are right next to the TV.  Otherwise, you may sit in comfortable chairs with your computer in your lap. Brilliant.  Oh, and they have very expensive, very bad food, none of which is vegetarian. Which is why I went out to eat in the first place.

OK, back to work….

Posted in z Silverlight Archives | Comments Off on O’Hare is a Very Big Place

What is coming soon?

You have noticed, I’m sure, that there has been a flurry of blogging, videos and more since the release of Beta 2. That is all goodness, though it can be hard to know where to start; and the road map will differ depending on where you are in your experience with Silverlight.

This is a rapidly changing environment and I’m hesitant to make promises, because things can change, but after some thought I’ve decided that it would be helpful to give you an idea of what to expect with my tutorials, videos and webcasts.  So, here is my tentative schedule through the next couple months.

WebCasts

LiveFromRedmond1

  • Styles and Templates  Wednesday June 18 9am UTC –8 (Pacific)
  • Deep Zoom Wednesday, July 16, 2008 9:00

Tutorials

All of the tutorials are updated to Beta 2 in their  pdf form and the HTML will be updated very soon. All of the source code is already updated.  The next couple tutorials will include

  • Styles, Templates, the Visual State Manager
  • Graphics, Transforms, and Animation
  • Animation In Detail
  • The DataGrid in Detail

Book

Tim and I are working hard to write and publish Programming Silverlight 2.  Our hope is to be able to provide an early look very soon. Here is one paragraph from my non-introduction (unedited and unauthorized)

We’ve set out to tell you the story of Silverlight and to teach you everything you need to know to program effectively with what we believe is an amazing new technology.

We have not tried to replicate the documentation nor to provide a comprehensive definition of every property, event and method of the framework. But telling the story of Silverlight is more than just picking which parts are most important; it is threading our way through a very large and complex framework in a coherent and logical way, making sense of it, and providing a guided tour through the underbrush pointing out the dangerous spots, showing the shortcuts, and warning of the dead-ends.

How Do I  Videos

In addition to the many videos already posted it is my plan to create videos on the following topics in the coming weeks.

  • Styles 
  • Templates and Visual State Manager
  • The Visual State Manager In Depth
  • Basic Animation in Beta 2 (with Blend)
  • Inter-state animation
  • In-state Animation
  • Graphics and transforms
  • Animating objects
  • Data and Animation
  • DataGrid
  • Advanced DataGrid
  • Popup Control
  • Calendar Control
  • TextBox In Depth
  • Scroll Bars

If your favorite topic is missing, just drop me a note.  Please note that some of these topics are covered already, but, in my opinion, more from a designer perspective than a developer perspective. I intend to focus on all these topics entirely from the perspective of the working developer.

Posted in z Silverlight Archives | Comments Off on What is coming soon?

Beta 2 Tutorials Available Now in PDF

I’m pleased to announce that the following tutorials are now updated for Beta 2 and available for immediate download (but only the PDF versions and the code have been updated so far, the HTML versions are not yet updated)

1 Creating Applications With Controls and Events

2 Binding Data In Silverlight

3 Filling a DataGrid using Sql, Linq and WCF

4 Instant Code Reuse: User Controls in Silverlight

5 Introducing Expression Blend For Silverlight Developers

To be perfectly clear:

  • The downloadable code is updated for Beta 2
  • The PDF is updated for Beta 2
  • The HTML is not updated  to Beta 2

We’ll have the HTML updated as soon as possible.

There will be a lot of information coming very fast in the next few hours and days. I recommend beginning your explorations with ScottGu’s blog post and then working your way through our new videos, tutorials, and the many other blog posts that will be appearing in the next couple days.

Exciting times.

Posted in z Silverlight Archives | 1 Comment

Popup Control

Beta 2 includes a wealth of new controls including the Popup (that is new, right? It’s not that I just didn’t notice it before?).

I received an email today asking if I’d do a short How Do I video on creating a Popup and I certainly will, but here is a wicked fast tutorial for those of you who can’t wait….

There are three approaches.

1. Create the Popup as Xaml, most easily in Blend

2. Create the Popup dynamically, most easily in Visual Studio

3. Create the Popup as a User Control (the right answer, once you’re comfortable with how Popups are created

 

Creating the Popup in Xaml

Here is a picture of what we’re going to build. The basic Silverlight control will have a button and an image…..

PopupNotShowing

The button’s event handler makes the Popup visible.

PopUpShowing

If you are old enough to get the reference, from having watched it when it was first on, remind me to buy you a glass of milk the next time we’re at a conference together

There are two important things to notice:

  • the Popup covers any elements that are at  its location (when you create it you give it a vertical and horizontal offset from the upper left of the control) and
  • the Popup is entirely within the Silverlight control.

Method 1 – Xaml

 

Create your basic project with the Click Me button and the Image in Blend. Set their properties as usual.

ObjectsInBlend

Then select a Popup from the Asset Library

AssetLibrary

and place that inside your Grid as well. Make the Popup the container by double clicking on it, and you are ready to add the border and StackPanel. Double click on the panel to make it  the container and add the TextBlock and Button.  Set all the properties.

Once you have the controls set, it is time to save all the files and edit in Visual Studio.

Your Xaml file will look more or less like this:

<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="PopUpControl.Page"
   xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
   xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
   mc:Ignorable="d"
    Width="640" Height="480" >

    <Grid x:Name="LayoutRoot" Background="White" >
        <Grid.RowDefinitions>
            <RowDefinition Height="0.15*"/>
            <RowDefinition Height="0.85*"/>
        </Grid.RowDefinitions>
      
        <Button x:Name="ShowPopupButton"
               Height="40" 
              HorizontalAlignment="Left" 
              VerticalAlignment="Bottom" 
              Width="100" 
              FontFamily="Comic Sans MS" 
              FontSize="24" 
              Content="Click me!"/>
        <Image x:Name="LandscapeImage"
             Margin="20,5,50,50" 
             Grid.Row="1"  
             Source="Desert Landscape.jpg" 
             HorizontalAlignment="Left" 
             VerticalAlignment="Top"/>
      
        <Popup x:Name="MyPopup" 
             VerticalOffset="75" 
             HorizontalOffset="25">
         <Border BorderBrush="Black" BorderThickness="5">
               <StackPanel x:Name="PopUpPanel" 
                        Background="#FFB9F4E2"
                        Height="Auto" Width="Auto" >
                   <TextBlock  x:Name="PopUpText"
                  Height="143" Width="Auto" 
                      Text="Danger Will Robinson!!"  
                      FontFamily="Comic Sans MS" FontSize="48" 
                  HorizontalAlignment="Center" VerticalAlignment="Center" 
                  Foreground="#FFD91F1F"/>
                   <Button x:Name="ClosePopup"
                       Height="34" 
                       Width="73" 
                       Content="Close" 
                       Background="#FF86F922" 
                       FontFamily="Verdana" FontSize="14" />
               </StackPanel>
         </Border>
        </Popup>
    </Grid>
</UserControl>

Notice that the Popup has a VerticalOffset and a HorizontalOffset; that positions it with respect to the upper left hand corner of the Silverlight control.

The Code-behind

The Constructor sets up Page_Loaded which in turn sets up the event handlers for the two buttons,

public Page()
{
    // Required to initialize variables
    InitializeComponent();
   Loaded += new RoutedEventHandler( Page_Loaded );
} 

void Page_Loaded( object sender, RoutedEventArgs e )
{
   ShowPopup.Click += new RoutedEventHandler( ShowPopup_Click );
   ClosePopup.Click += new RoutedEventHandler( ClosePopup_Click );
} 

void ClosePopup_Click( object sender, RoutedEventArgs e )
{
   MyPopup.IsOpen = false;
} 

void ShowPopup_Click( object sender, RoutedEventArgs e )
{
   MyPopup.IsOpen = true;
}

Creating the Popup Dynamically

 

An alternative approach is to set up the first button and the image as before, but to create the Popup in code.  In your Xaml file you just eliminate the Popup altogether. No other changes. The big change is in the code-behind:

using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Controls.Primitives;

namespace PopUpInCode
{
   public partial class Page : UserControl
   {
      private Popup myPopup = new Popup();

      public Page()
      {
         InitializeComponent();
         Loaded += new RoutedEventHandler( Page_Loaded );
      }

      void Page_Loaded( object sender, RoutedEventArgs e )
      {
         ShowPopup.Click += new RoutedEventHandler( ShowPopup_Click );  
      }

      void ShowPopup_Click( object sender, RoutedEventArgs e )
      {


         Border border = new Border();
         border.BorderBrush = new SolidColorBrush( Colors.Black );
         border.BorderThickness = new Thickness( 5.0 );


         StackPanel myStackPanel = new StackPanel();
         myStackPanel.Background = new SolidColorBrush( Colors.LightGray );
         

         TextBlock tb = new TextBlock();
         tb.Text = "Danger Will Robinson!!";
         tb.FontFamily = new FontFamily("Comic Sans MS");
         tb.FontSize = 48.0;
         tb.HorizontalAlignment = HorizontalAlignment.Left;
         tb.VerticalAlignment = VerticalAlignment.Center;
         tb.Foreground = new SolidColorBrush( Colors.Black );


         Button closePopup = new Button();
         closePopup.Content = "Close";
         closePopup.Background = new SolidColorBrush( Colors.Magenta );
         closePopup.FontFamily = new FontFamily( "Verdana" );
         closePopup.FontSize = 14.0;
         closePopup.Width = 50.0;
         closePopup.Click += new RoutedEventHandler(ClosePopup_Click);
         closePopup.Margin = new Thickness( 10 );



         myStackPanel.Children.Add( tb );
         myStackPanel.Children.Add( closePopup );

         border.Child = myStackPanel;

         myPopup.Child = border;

         myPopup.VerticalOffset = 75.0;
         myPopup.HorizontalOffset = 25.0;
         myPopup.IsOpen = true;
      }

      void ClosePopup_Click( object sender, RoutedEventArgs e )
      {
         myPopup.IsOpen = false;
      }
   }
}

You’ll notice that I hewed pretty close in the code to what I had created in the Xaml without making myself too crazy. 

The Third, and Right Way

The right way to do this, now that I’ve shown all that, is to make the Popup as a UserControl, which of course you can create as a separate .xaml file and design beautifully in Blend. then the PopUp has only to contain your UserControl and you are all set.

I’ll show that in the video. (Hey! I need something to add in the video).

Thanks.

-jesse

 

Source code  How to use this source code

Posted in z Silverlight Archives | 4 Comments

Beta 2 Month

Beta 2 has been announced, and as you may know from Tim’s post and Karen Corby’s, one of the big and wonderful additions to Beta 2 is a new model for skinning Silverlight controls. There are a lot of other new additions as well, and I'd like to dedicate June to tutorials, videos and blog posts about some of the most exciting.

The timing is good, because I just finished updating all the tutorials for Beta 2 (watch for them to be posted shortly after Beta 2 is available) and the one I did not update is #3 Styles and Templates. 

I chose not to update that one because the new model is so much better there was no point in fixing up a tutorial on typewriters when computers are about to land on your desk.

 

typewriter

The Plan

During June I'll release

  • A new tutorial that covers Styles, Templates and the VSM in great detail
  • How Do I videos on Styles, Templates, Visual State Manager, and tying it all together
  • Videos on Animation, new controls, Data Binding improvements, and much more
  • Multiple “digging deeper” blog posts and…
  • June 18 – Round Buttons with Visual State Manager The first in my new series of Web casts unlike any I’ve tried before: much higher value, much more information, much more use of the medium.

This should just be a blast. 

 

So, sign up for the June 18 WebCast and don’t forget to join SLMicroBlog to be kept up to date.

 

 

 

 

 

 

 

 

 

Posted in z Silverlight Archives | Comments Off on Beta 2 Month

Beta 2 Event Bubbling

There are many great changes in Beta 2, and some are designed to make Silverlight more like WPF. One side effect of this is that event bubbling has changed just a bit and that bit breaks some of the examples I love to use.

In Beta 1, the distinction was that all the controls handled their own click events but the more primitive events such as many of the mouse events were allowed to bubble. This allowed for interesting if not terribly useful demonstrations in which I placed a check box inside a button and was able to demonstrate that if I were to use the click event on the check box the button would never see the click, but if I used a MouseLeftButtonDown, hey! Presto! the button did see the event.

This has now changed in Beta 2 to make Silverlight behave more like WPF. By and large (other than breaking my demo) this is a good thing.  The consistency now is that objects that directly derive from UI element do support event bubbling for the mouse events (that is,  Ellipse, Glyphs, Image, InkPresenter, Line, MediaElement, Path, Polygon, Polyline, Rectangle and TextBlock.)  In addition, the container classes do.

Thus, if you set up the following bizarre application in which you have a grid, with a grid in it, that contains a stack panel that in turn contains a rectangle, a TextBlock, a check box, a button and a listbox (the last to show the results)…

<UserControl x:Class="EventBubbling.Page"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    Width="400" Height="800">
    <Grid x:Name="LayoutRoot" Background="White">
        <Grid x:Name="InterimGrid" >
            <StackPanel x:Name="myStackPanel" Orientation="Vertical"  >
                <Rectangle x:Name="myRect" Width="30" Height="30" Fill="Blue"
                    Stroke="Red" StrokeThickness="2" Margin="0,10,0,10" />
                <TextBlock x:Name="myTextBlock" Text="Hello"  
                    HorizontalAlignment="Center" FontSize="14" Margin="0,10,0,10"/>
                <CheckBox x:Name="myCheckBox" Content="Check Me" Width="80" 
                    Height="40" Margin="0,10,0,10" HorizontalAlignment="Center" />
                <Button x:Name="myButton" Content="TinyButton" Height="30" 
                    Width="70" Margin="0,10,0,10" FontSize="12" HorizontalAlignment="Center" />
                <ListBox x:Name="Messages" Width="150" Height="400" />      
        </StackPanel>
      </Grid>
    </Grid>
</UserControl>

and you add MouseLeftButtonDown event handlers for everything (except the list box):

void Page_Loaded(object sender, RoutedEventArgs e)
{
    LayoutRoot.MouseLeftButtonDown += new MouseButtonEventHandler(
        LayoutRoot_MouseLeftButtonDown);
    InterimGrid.MouseLeftButtonDown += new MouseButtonEventHandler(
        InterimGrid_MouseLeftButtonDown);
    myStackPanel.MouseLeftButtonDown += new MouseButtonEventHandler(
        myStackPanel_MouseLeftButtonDown);
    myRect.MouseLeftButtonDown += new MouseButtonEventHandler(
        myRect_MouseLeftButtonDown);
    myTextBlock.MouseLeftButtonDown += new MouseButtonEventHandler(
        myTextBlock_MouseLeftButtonDown);
    myCheckBox.MouseLeftButtonDown += new MouseButtonEventHandler(
        myCheckBox_MouseLeftButtonDown);
    myButton.MouseLeftButtonDown += new MouseButtonEventHandler(
        myButton_MouseLeftButtonDown);
}

 

 

 

where all the handlers do the same thing, they add to the list box (there are more efficient ways to write this!)

void InterimGrid_MouseLeftButtonDown(
    object sender, MouseButtonEventArgs e)
{
    Messages.Items.Add(" InterimGrid ");
}

What you find is that when you click on the rectangle or the text block the event bubbles all the way to the top most grid, but if you click on the checkbox or the button the event is “handled” by that control and is not bubbled at all.

BubblingNoMore

In the image, I’ve clicked on the rectangle and the event was registered by the rectangle, the StackPanel that encloses it, the Grid that holds the StackPanel and the outermost grid.  I’m now clicking on the button, and while the button is registering the mouse down, it is not passing it along to anyone else.

One fascinating aspect of this (at least to me, but I don’t get out much) is that if I inject a button into the middle of the stream, by putting the rectangle, textblock checkbox and button inside an outer button…

<UserControl x:Class="EventBubbling.Page"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    Width="400" Height="600">
    <Grid x:Name="LayoutRoot" Background="White">
        <Grid x:Name="InterimGrid" >
            <Grid.RowDefinitions>
                <RowDefinition Height="120" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <Button x:Name="OuterButton" Width="300" Height="100" Grid.Row="0">
                <StackPanel x:Name="myStackPanel" Orientation="Horizontal"  >
                    <Rectangle x:Name="myRect" Width="50" Height="30" Fill="Blue"
                        Stroke="Red" StrokeThickness="2" Margin="5,0,5,0" />
                    <TextBlock x:Name="myTextBlock" Text="Hello"  
                        VerticalAlignment="Center" FontSize="14" Margin="5,0,5,0"/>
                    <CheckBox x:Name="myCheckBox" Content="Check Me" Width="80" 
                        Height="40" Margin="5,0,5,0" VerticalAlignment="Center" />
                    <Button x:Name="myButton" Content="TinyButton" Height="30" 
                        Width="70" Margin="5,0,5,0" FontSize="12" VerticalAlignment="Center" />
                </StackPanel>
            </Button>
            <ListBox x:Name="Messages" Width="150" Height="400" Grid.Row="1"/>      
        </Grid>
    </Grid>
</UserControl>

The key changes are that I’ve created two rows (one for the controls, one for the list box) and injected a button above the stack panel that holds the stack panel and all its contents (now horizontal). Let’s run the same experiment…

BubblingNoMore2

Once again, I clicked on the Rectangle, and then was clicking on the button when I took the image. Once again the button had no bubbling, but notice that the Rectangle did not bubble as far as it had previously. After it hit the stack panel it hit the outer button which ate the MouseLeftButtonDown event, and did not pass it along to any containers above it.

All of this is as it should be, and will end a lot of confusion for folks coming over from WPF, but if you learned about bubbling from me, then you’ll want to know about this change.

(Source code posted when Beta2 Ships)

Thanks

Posted in z Silverlight Archives | 1 Comment

Creating a Project from xaml and xaml.cs files

I posted the code for the PageSwitcher app described in a previous blog post, but to save space and to make the download faster, I didn't include anything but the code (no solution or project files). A reader wrote asking how to create a project and it is a more than fair question as the answer is not obvious until you've done it a couple times, so let's walk through that example.

When you download the code, you'll receive a zip file named  PageSwitcher.zip. Unzip that and you'll have a folder named PageSwitcher,

PageSwitcherFiles

 

Open a new Visual Studio project and to make this example as clear as possible, let's name it something else (myPageSwitcher) and locate it in a different directory.

Open Page.xaml in your new project and note the name of the project (MyPageSwitcher)

<UserControl x:Class="MyPageSwitcher.Page"

Open Page.xaml.cs and note the namespace

namespace MyPageSwitcher

This is the information you need to hold on to for the rest of this exercise.

Ready To Go

There are many ways to do this, but the easiest is to delete Page.xaml, Page.xaml.cs and App.xaml and App.xaml.cs from your new project. (Don't panic!)

Next, right-click on the project and choose Add->Existing items and navigate to the downloaded files and add them all. They are now in your new project.

Click on all 4 xaml files and change the name of the project in the x:Class tag.

Click on all 4 .cs files and change the name of the namespace (ignore the smart tag) If you want to get rid of the smart tag, use Build->Clean. Build->Rebuild Solution.

You're all set

Here is your new PageSwitcher.xaml

<UserControl x:Class="MyPageSwitcher.PageSwitcher"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    Width="400" Height="300">

</UserControl>

 

And here is your new PageSwitcher.xaml.cs

using System.Windows.Controls;

namespace MyPageSwitcher
{
    public partial class PageSwitcher : UserControl
    {
        public PageSwitcher()
        {
            InitializeComponent();
            if (this.Content == null)
            {
                this.Content = new Page();
            }
        }
        public void Navigate(UserControl nextPage)
        {
            this.Content = nextPage;
        }
    }
}

 

Don't forget, once your code compiles, you can right click on the using statements and choose Organize Usings -> Remove Unused Using  which greatly cleans up your code.

RemoveUnusedUsing

Posted in z Silverlight Archives | 1 Comment

Blog Post of the Month

Every once in a while I read a blog post that is so good I have to pass it on. Scott Hanselman said it perfectly today.

Posted in z Silverlight Archives | Comments Off on Blog Post of the Month