WP7 - 异步更新ListPicker项

时间:2013-02-22 00:35:03

标签: windows-phone-7 mvvm

在这种情况下,我不能在ListPicker中看到列表中的值吗?

XAML

<toolkit:ListPicker
                x:Name="lpkBoards"
                ItemsSource="{Binding AllBoards}"
                DisplayMemberPath="Name" >
                </toolkit:ListPicker>

xaml.cs

public SettingsPage()
        {
            InitializeComponent();

            // Set the page DataContext property to the ViewModel.
            this.DataContext = App.ViewModel;

         ...

            boardsTask.ContinueWith(
                (call) =>
                {
                    App.ViewModel.AllBoards = call.Result.ToList();

                }
                );

视图模型

// All to-do items.
private List<Board> _allBoards;
public List<Board> AllBoards
{
    get { return _allBoards; }
    set
    {
        _allBoards = value;
        NotifyPropertyChanged("AllBoards");
    }
}

1 个答案:

答案 0 :(得分:1)

如果您尝试将其绑定到UI元素并希望它能够正常工作,则需要将List<Board>更改为ObservalbeCollection<Board>