如何添加监听器在.NET中已经定义的属性 [英] How to add listener to the property already defined in .NET

查看:105
本文介绍了如何添加监听器在.NET中已经定义的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望收到通知时, 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);

看<一href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/microsoft.phone.net.networkinformation.devicenetworkinformation.networkavailabilitychanged%28v=vs.105%29.aspx"相对=nofollow> NetworkAvailabilityChanged事件充分说明

这篇关于如何添加监听器在.NET中已经定义的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆