0
votes

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.

1

1 Answers

1
votes

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.