我遇到ObservableCollection类的问题。我无法解决这个问题。无法解析符号T
using System.Collections.ObjectModel;
#region ViewModelProperty: CustomerList
private ObservableCollection<T> _customerList = new ObservableCollection<T>();
public ObservableCollection<T> CustomerList
{
get
{
return _customerList;
}
set
{
_customerList = value;
OnPropertyChanged("CustomerList");
}
}
#endregion
我与的ObservableCollection类继承ViewModelBase:
public abstract class ViewModelBase : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(string propertyName)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(propertyName));
}
}
}
任何想法,问题出在哪里?
我有两种不同的类型,我添加此集合请参阅: http://msdn.microsoft.com/en-us/library/ms668604.aspx – 2009-08-14 07:37:23
您仍然需要用特定类型替换T.如果你的不同类型有一个共同的基类,你可以将它用于T.如果它们不是,你可以使用对象,但在这种情况下,你可能想考虑改变你的设计。 – 2009-08-14 07:41:40