PanuonUI.Silver
PanuonUI.Silver copied to clipboard
DataGrid的一个小问题
列表如果之前的数据排序过再更改数据刷新之后没反应,必须再点一次排序(表头)才会刷新列表
上代码
public class SearchListItemModel : INotifyPropertyChanged
{
[DisplayName(" ")]
public bool IsSelected { get; set; }
[DisplayName("标题")]
public string Title { get; set; }
[DisplayName("歌手")]
public string Singer { get; set; }
[DisplayName("专辑")]
public string Album { get; set; }
public event PropertyChangedEventHandler PropertyChanged;
public void OnPropertyChanged(string propertyName)
{
if (this.PropertyChanged != null)
this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
List.ItemsSource = SearchListItem;
List.Items.Refresh();
我并未看到你在属性中使用OnPropertyChanged。。你的ItemsSource是否为ObservableCollection?另外赋值后为何还要刷新Items?