O'Reilly logo

Microsoft Silverlight 4 Business Application Development Beginner's Guide by Frank LaVigne, Cameron Albert

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action - detecting network connectivity

Let's see how to use the GetIsNetworkAvailable method and the NetworkAddressChanged event together in making a more connection savvy solution.

  1. Create a new Silverlight application in Visual Studio and name it OfflineTestApp.
  2. Add the following XAML code to the Grid named LayoutRoot in the MainPage.xaml file:
    <Ellipse x:Name="ellipseIndicator"
    Height="82"
    HorizontalAlignment="Center"
    Stroke="Black"
    Fill="Gray"
    StrokeThickness="1"
    VerticalAlignment="Top"
    Width="86" />
    
  3. In the MainPage.xaml.cs file, add this line of code to the MainPage constructor method, right after the InitializeComponent method call:
    NetworkChange.NetworkAddressChanged += new NetworkAddressChangedEventHandler(NetworkChange_NetworkAddressChanged); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required