问题描述:绑定到ICollectionView不显示任何内容。
解决方法:
ICollectionView myCollectionView = CollectionViewSource.GetDefaultView(MyDataCollection);
myCollectionView.Refresh();
ICollectionView myCollectionView = CollectionViewSource.GetDefaultView(MyDataCollection);
myCollectionView.Filter = new Predicate
ICollectionView myCollectionView = CollectionViewSource.GetDefaultView(MyDataCollection);
myCollectionView.SortDescriptions.Add(new SortDescription("PropertyName", ListSortDirection.Ascending));
public class MyDataModel : INotifyPropertyChanged
{
private string _propertyName;
public string PropertyName
{
get { return _propertyName; }
set
{
if (_propertyName != value)
{
_propertyName = value;
OnPropertyChanged(nameof(PropertyName));
}
}
}
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
以上是一些常见的解决方法,具体解决方法还要根据实际情况进行调试和处理。