Silverlight中常用知识总结
来源:互联网 发布:软件无线电 微盘 编辑:程序博客网 时间:2024/06/06 08:54
public abstract class NotificationObject : INotifyPropertyChanged{ public event PropertyChangedEventHandler PropertyChanged; protected virtual void RaisePropertyChanged(string propertyName) { PropertyChangedEventHandler handler = this.PropertyChanged; if (handler != null) { handler(this, new PropertyChangedEventArgs(propertyName)); } } protected void RaisePropertyChanged(params string[] propertyNames) { if (propertyNames == null) throw new ArgumentNullException("propertyNames"); foreach (var name in propertyNames) { this.RaisePropertyChanged(name); } } protected void RaisePropertyChanged<T>(Expression<Func<T>> propertyExpression) { var propertyName = ExtractPropertyName(propertyExpression); this.RaisePropertyChanged(propertyName); } public static string ExtractPropertyName<T>(Expression<Func<T>> propertyExpression) { if (propertyExpression == null) { throw new ArgumentNullException("propertyExpression"); } var memberExpression = propertyExpression.Body as MemberExpression; if (memberExpression == null) { throw new ArgumentException("PropertySupport_NotMemberAccessExpression_Exception", "propertyExpression"); } var property = memberExpression.Member as PropertyInfo; if (property == null) { throw new ArgumentException("PropertySupport_ExpressionNotProperty_Exception", "propertyExpression"); } var getMethod = property.GetGetMethod(true); if (getMethod.IsStatic) { throw new ArgumentException("PropertySupport_StaticExpression_Exception", "propertyExpression"); } return memberExpression.Member.Name; }}相应的,Student类型为:public class Student : NotificationObject{ string firstName; public string FirstName { get { return firstName; } set { firstName = value; //Notify("FirstName"); this.RaisePropertyChanged("FirstName"); } } string lastName; public string LastName { get { return lastName; } set { lastName = value; //Notify("LastName"); this.RaisePropertyChanged("LastName"); } } public Student(string firstName, string lastName) { this.firstName = firstName; this.lastName = lastName; } }
Windows Phone7获取当前网络状态
using Microsoft.Phone.Net.NetworkInformation;... string netState, netName; private bool _networkIsAvailable; private NetworkInterfaceType _currentNetworkType; //网络连接的类型 private void GetNetInfo(object sender, RoutedEventArgs e) { _networkIsAvailable = NetworkInterface.GetIsNetworkAvailable();//当前网络是否可用 _currentNetworkType = NetworkInterface.NetworkInterfaceType;//获取当前网络的类型 if (_networkIsAvailable) { netState = "联网状态"; //Message.Background = new SolidColorBrush(Colors.Green); } else { netState = "断网状态"; //Message.Background = new SolidColorBrush(Colors.Red); } switch (_currentNetworkType) { case NetworkInterfaceType.MobileBroadbandCdma: netName = "CDMA网络"; break; case NetworkInterfaceType.MobileBroadbandGsm: netName = "CSM网络"; break; case NetworkInterfaceType.Wireless80211: netName = "Wi-Fi网络"; break; case NetworkInterfaceType.Ethernet: netName = "Ethernet网络"; break; case NetworkInterfaceType.None: netName = "网络不可用"; break; default: netName = "其他的网络"; break; } }...
- Silverlight中常用知识总结
- Silverlight常用小知识总结(不断更新中)
- Silverlight 常用小知识点总结
- shell常用知识总结
- 常用小知识总结
- jquery常用知识总结
- domino常用知识总结
- Oracle常用知识总结
- iOS 常用知识总结
- Android 常用知识总结
- iOS常用知识总结
- 常用Shell知识总结
- xml常用知识总结
- AVRO : 常用知识总结
- MySQL常用知识总结
- git 常用知识总结
- composer常用知识总结
- jQuery常用知识总结
- 这就是生活
- SQL查询的基本原理
- 地图分幅组件的实现(七)——非标准制图过程的自动化
- UBuntu 安装无线网卡
- RedHat Linux中的vi命令(这个比较全了)
- Silverlight中常用知识总结
- Ubuntu9.04下装TP-Link WN322g+2.0(AR9271芯片)无限网卡驱动
- MyEclipse9 注册码过期的解决方法(64位win7)
- SQL异地备份
- jquery语法总结和注意事项
- apache服务器性能研究
- HTML5中的 querySelector
- 统一设置Eclipse编码
- 亚马逊低价Pad入华暂无时间表