【发布时间】:2014-02-13 17:33:13
【问题描述】:
我有一个静态对象[] 数组(500 多个项目),每秒更改一次,并且有许多控件需要显示该数组中包含的数据。我需要这个数组是静态的,因为它在许多其他类中使用。
是否可以在 .NET 4.5 中实现这种绑定?我正在尝试下面的代码但没有成功(基于 http://www.jonathanantoine.com/2011/09/28/wpf-4-5-%E2%80%93-part-9-binding-to-static-properties/ )。编译时出现“Playback.Control”未实现接口成员“System.ComponentModel.INotifyPropertyChanged.PropertyChanged”错误
public class Control : INotifyPropertyChanged
{
public static event EventHandler<PropertyChangedEventArgs> StaticPropertyChanged;
public static void RaiseChangeEvent(string propName)
{
EventHandler<PropertyChangedEventArgs> handler = StaticPropertyChanged;
if (handler != null)
handler(null, new PropertyChangedEventArgs(propName));
}
private static int _playposition;
public static int PlayPosition { get { return _playposition; } set { if (_playposition == value) return; _playposition = value; RaiseChangeEvent("PlayPosition"); } }
public static DataTable JobData { get; private set; }
private static Object[] _currentdata;
public static Object[] CurrentData { get { return _currentdata; } set { if (_currentdata == value) return; _currentdata = value; RaiseChangeEvent("CurrentData"); } }
private static Object[] _previousdata;
public static Object[] PreviousData { get { return _previousdata; } set { if (_previousdata == value) return; _previousdata = value; RaiseChangeEvent("PreviousData"); } }
}
【问题讨论】:
标签: c# .net wpf data-binding