PanuonUI.Silver icon indicating copy to clipboard operation
PanuonUI.Silver copied to clipboard

DataGrid的一个小问题

Open gl0zzy opened this issue 4 years ago • 3 comments

列表如果之前的数据排序过再更改数据刷新之后没反应,必须再点一次排序(表头)才会刷新列表

gl0zzy avatar Jul 09 '20 15:07 gl0zzy

上代码

Mochengvia avatar Jul 14 '20 03:07 Mochengvia

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();

gl0zzy avatar Jul 14 '20 03:07 gl0zzy

我并未看到你在属性中使用OnPropertyChanged。。你的ItemsSource是否为ObservableCollection?另外赋值后为何还要刷新Items?

Mochengvia avatar Dec 16 '20 05:12 Mochengvia