问题描述
我希望收到通知时, NetworkInterfaceType
将从 NetworkInterfaceType.MobileBroadbandGsm
更改为 NetworkInterfaceType.Wireless80211
和周围的其他方式:
I want to be notified when the NetworkInterfaceType
will change from NetworkInterfaceType.MobileBroadbandGsm
to NetworkInterfaceType.Wireless80211
and the other way around:
var info = Microsoft.Phone.Net.NetworkInformation.NetworkInterface.NetworkInterfaceType;
如何做到这一点?我想补充一个监听器,将侦听的属性的更改。
试过了:
<$c$c>System.ComponentModel.DependencyPropertyDescriptor.FromProperty(Microsoft.Phone.Net.NetworkInformation.NetworkInterface.NetworkInterfaceType, typeof运算(NetworkInterfaceType))AddValueChanged(资讯,(S,E)=&GT; {System.Diagnostics.Debug.WriteLine(fsajfopsajopfasjopfsaj);});
但这不是可以在WP8。
but this is not available in WP8.
推荐答案
您必须订阅NetworkAvailabilityChanged如下:
You have to subscribe to the NetworkAvailabilityChanged as follow:
DeviceNetworkInformation.NetworkAvailabilityChanged += new EventHandler<NetworkNotificationEventArgs>(NetworkAvailabilityChanged);
看 NetworkAvailabilityChanged事件充分说明
这篇关于如何添加监听器在.NET中已经定义的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!