Windows Phone 8.1 - ListView绑定问题mvvm light

时间:2016-03-06 09:01:58

标签: c# xaml windows-phone-8.1

我的绑定有一个奇怪的问题......

目前我只想尝试在列表视图中绑定对象列表

XAML

ExtendedListView只是基本列表视图的扩展。

<refresh:ExtendedListView PullToRefreshRequested="listView_InfoRefresh" IsPullToRefreshEnabled="True" ItemsSource="{Binding MyList, Mode=OneWay}" >
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Vertical">
                            <TextBlock FontSize="16">
                                <Run x:Uid="TheChallenge" />
                                <Run Text="{Binding Title}"/>
                                <Run x:Uid="ExpireChallenge" />
                            </TextBlock>
                        </StackPanel>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </refresh:ExtendedListView>

C#

private List<Challenge> myList;

        public List<Challenge> MyList
        {
            get { return myList; }
            set
            {
                if (myList!= value)
                {
                    myList= value;
                    RaisePropertyChanged(() => MyList);
                }
            }
        }

该列表是从Wep Api应用程序中检索的。 当我放置一个断点时,列表不为空(目前我的列表中有3个元素),并且在 MyList 绑定后,我可以在它们消失之前2秒看到这些项目。 ..

如果有人有想法。

1 个答案:

答案 0 :(得分:1)

使用List并在每次数据更改时进行设置都不是一个好主意。只需使用一个ObservableCollection,在ctor中设置juts一次,然后只添加和删除项目。

相关问题