DeviceNetworkInformation.NetworkAvailabilityChanged Event

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Occurs when the availability of the network changes. For example, an application can register for this event and get a notification if a WiFi network becomes available. The application could then adjust its behavior to take advantage of this high bandwidth network interface.

Namespace:  Microsoft.Phone.Net.NetworkInformation
Assembly:  Microsoft.Phone (in Microsoft.Phone.dll)


Public Shared Event NetworkAvailabilityChanged As EventHandler(Of NetworkNotificationEventArgs)
public static event EventHandler<NetworkNotificationEventArgs> NetworkAvailabilityChanged


The DeviceNetworkInformation class raises this event for network interface changes such as connecting, disconnecting, and changing roaming status.

To associate this event with a method that will handle the event, create a delegate and add an instance of the delegate to the event. The event handler is called whenever this event occurs, unless you remove the delegate. If an application resumes from a dormant state, the framework automatically re-registers the callback. In other words, you do not have to register for the event again.

For more information about handling events, see Consuming Events.


The following code example shows how to subscribe to the NetworkAvailabilityChanged event and determine what the changes were. It uses the NotificationType and NetworkInterface properties of the NetworkNotificationEventArgs to show the type of notification that was received as well as the name of the network interface for which the notification was received.

This example assumes you have a TextBlock in your application called textBlock1. This example also assumes that you have added the following using statements to your code window.

using Microsoft.Phone.Net.NetworkInformation;
using System.Windows;
using Microsoft.Phone.Tasks;
// Constructor
public MainPage()

   // Subscribe to the NetworkAvailabilityChanged event
   DeviceNetworkInformation.NetworkAvailabilityChanged += new EventHandler<NetworkNotificationEventArgs>(NetworkAvailabilityChanged);

void NetworkAvailabilityChanged(object sender, NetworkNotificationEventArgs e)

   string change = string.Empty;
   switch (e.NotificationType)
      case NetworkNotificationType.InterfaceConnected:
         change = "Connected to ";
      case NetworkNotificationType.InterfaceDisconnected:
         change = "Disconnected from ";
      case NetworkNotificationType.CharacteristicUpdate:
         change = "Characteristics changed for ";
         change = "Unknown change with ";

   string changeInformation = String.Format(" {0} {1} {2} ({3})", 
         DateTime.Now.ToString(), change, e.NetworkInterface.InterfaceName, 

   // Interacting with UI, so make sure this is done on the UI thread.
   Dispatcher.BeginInvoke(() =>
      textBlock1.Text += changeInformation;
      textBlock1.Text += Environment.NewLine;

Version Information

Windows Phone OS

Supported in: 8.1, 8.0, 7.1


Windows Phone

See Also


DeviceNetworkInformation Class

Microsoft.Phone.Net.NetworkInformation Namespace

Other Resources

How to detect network changes for Windows Phone 8