简体   繁体   中英

Windows Phone 8.1 - ListView binding issue mvvm light

I have a strange issue with my binding...

Currently I'm just trying to binding a list of objects in a list view

XAML

ExtendedListView is just an extension of the basic listview.

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

The list is retrieve from a Wep Api application. When I put a breakpoint, the list is not empty ( currently I have 3 elements in my list ), and after the binding of MyList , I am able to see the items 2 sec before they dissapear....

If someone have an idea.

Using a List and setting it every time data changes is not a good idea. Just use an ObservableCollection, set it juts once in ctor and then only add and remove items.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM