Copy and Paste the code below into your main page loading
--Constructor
this.Loaded += new RoutedEventHandler(LoginPage_Loaded);
#region Get Network Status
private void LoginPage_Loaded(object sender, RoutedEventArgs e)
{
GetNetworkStatus();
NetworkChange.NetworkAddressChanged += new
NetworkAddressChangedEventHandler(NetworkChange_NetworkAddressChanged);
}
private void NetworkChange_NetworkAddressChanged(object sender, EventArgs e)
{
GetNetworkStatus();
}
private void GetNetworkStatus()
{
_dataContext.Online = NetworkInterface.GetIsNetworkAvailable();
if (!_dataContext.Online)
{
//no internet connection
_dataContext.Message = "Internet connection is not available";
}
else
{
//Load All user Data.
_dataContext.LoadData();
}
}
#endregion
No comments:
Post a Comment