排序不变 [英] Sorting does not change

查看:101
本文介绍了排序不变的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

我在WPF应用程序中具有ListView,其中显示了所有播放器,

 i've ListView in WPF Application which display all Players ,

游戏名称和

排序方式:得分降序

            PlayersList.ItemsSource = myList;  
            CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(PlayersList.ItemsSource);
            PropertyGroupDescription groupDescription = new PropertyGroupDescription("Game");
            SortDescription sd = new SortDescription("Score", ListSortDirection.Descending);
            view.SortDescriptions.Add(sd);
            view.GroupDescriptions.Add(groupDescription);

当我更新特定用户的分数时,它工作正常

it works fine , when i am updating  the score of specific user

ScoreHistory param = myList.FirstOrDefault(z => z.Player == userName );
                    if (param != null)
                    {
                        param.Score = newscore;
                         
                    }

分数得到了很好的更新,但是分数的排序或排名没有变化.

The score is well updated but the sorting or the ranking of scores does not change.

public class ScoreHistory : INotifyPropertyChanged
    {
     private string _player;
    public string Player
    {
        get { return _player; }
        set
        {
            if (_player != value)
            {
                _player = value;
                OnPropertyChanged("Player");
            }
        }
    } 
	
	
	
    private int _score;
    public int Score
    {
        get { return _score; }
        set
        {
            if (_score != value)
            {
                _score = value;
                OnPropertyChanged("Score");
            }
        }
    }
     

   
        private string _game;
        public string Game
        {
            get { return _game; }
            set
            {
                if (_game != value)
                {
                    _game = value;
                    OnPropertyChanged("Game");
                }
            }
        }
       


         
    public event PropertyChangedEventHandler PropertyChanged;
    protected void OnPropertyChanged(string p_strPropertyName)
    {
        if (PropertyChanged != null)
            PropertyChanged(this, new PropertyChangedEventArgs(p_strPropertyName));
    }


}

请帮助我,我的代码有什么问题?

Please help me, what's wrong in my code ?

谢谢

推荐答案

您是否尝试过在 view 上调用 Refesh()方法> 变量?
Have you tried calling the Refesh() method on view variable ?


这篇关于排序不变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆