Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

ListView Itemssource property is not updating changes to an observablecollection

$
0
0

In the following code im binding Records form a viewmodel , which is using an observablecollection , im also raising the inotifypropertychange, , now i have a button setup which uses the navigation.pushasync method to go to a new page , over there im updating the database Records , i have created a listview in this new page and used the same binding shown here to bind the Records , whenever i add something it updates , but if i press the back button and come back to this EntryTabPage the binding doesnt update , it only updates if i close the app fully and restart it the data is shown.

I want this listview to be updated not sure how to do it , i have tried using the onappearing and typing in the Listviewname.itemssource=Records; but this is showing an error "this does not exist in the current context" any help in the right direction would be appreciated.

       namespace Bunk_Master
    {
        [XamlCompilation(XamlCompilationOptions.Compile)]
        public partial class EntryPageTab1 : ContentPage
        {

            public EntryPageTab1()
            {
                InitializeComponent();
                BindingContext = new ClassViewModel();


                addclassbutton.Clicked += async (object sender, EventArgs e) =>
                 {
                     await this.Navigation.PushAsync(new AddClass());
                 };


            }

                  protected override void OnAppearing()
            {


                base.OnAppearing();

            }



        }

This is the xaml

            <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
                         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                         x:Class="Bunk_Master.EntryPageTab1"
                         Title="Default">
                <StackLayout x:Name="stacklayout">
                    <ListView ItemsSource="{Binding Records}"
                              x:Name="classListView">
                        <ListView.ItemTemplate>
                            <DataTemplate>
                                <TextCell Text="{Binding}">

                                </TextCell>
                            </DataTemplate>
                        </ListView.ItemTemplate>
                    </ListView>
                    <Button Text="new"
                            x:Name="addclassbutton">

                    </Button>


                </StackLayout>
            </ContentPage>

Viewing all articles
Browse latest Browse all 91519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>