【发布时间】:2026-01-29 04:50:02
【问题描述】:
我的 wcf 服务中定义了以下类
public class Autoturism : INotifyPropertyChanged
{
private int _AutoturismID;
public int AutoturismID
{ get { return _AutoturismID; } set { _AutoturismID = value; NotifyPropertyChanged("AutoturismID"); } }
private string _NumarAutoturism;
public string NumarAutoturism
{ get { return _NumarAutoturism; } set { _NumarAutoturism = value; NotifyPropertyChanged("NumarAutoturism"); } }
public bool IsDirty { get; set; }
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged(String info)
{
IsDirty = true;
if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs(info));
}
我想使用 IsDirty 值来检查对象是否需要保存在数据库中。
在 silverlight 页面中,我有以下几行:
AutoCurent = new Autoturism();
AutoCurent.NumarAutoturism="13424";
我的问题是,在最后一行之后,我期望 IsDirty= true 但它仍然是错误的。我认为来自服务引用的 Auoturism 类不再具有 NotifyPropertyChanged 方法。
我做错了什么? 谢谢
【问题讨论】:
-
+1 提供大量代码和良好的描述:)
标签: c# silverlight wcf inotifypropertychanged