小编Sha*_*ead的帖子

使用自定义ItemsSource刷新ListBox的最简单方法?

我正在使用带有自定义ItemsSource的ListBox:

this.ListOfPersonsListBox.ItemsSource = (List<Person>)ListOfPersons.AllPersons;
Run Code Online (Sandbox Code Playgroud)

ListOfPersons是一个静态类,因此它无法实现INotifyPropertyChanged和IObservableCollection.

更新列表后重绘ListBox的最简单方法是什么?我目前的代码有效,但我想找到一个更清洁的解决方案:

    private void SyncButton_Click(object sender, EventArgs e)
    {
        ListOfPersons.Sync();
        this.ListOfPersonsListBox.ItemsSource = null;
        this.ListOfPersonsListBox.ItemsSource = ListOfPersons.AllPersons;
    }
Run Code Online (Sandbox Code Playgroud)

c# silverlight xaml windows-phone-7

7
推荐指数
1
解决办法
8298
查看次数

标签 统计

c# ×1

silverlight ×1

windows-phone-7 ×1

xaml ×1