简体   繁体   中英

Windows Phone 8 - Binding

I have a WP8 Pivot application which contains a Model that is meant to automatically bind against the View/Page.xaml. This is done by the auto-generated NotfifyPropertyChanged code which I have assigned to all of the properties that are spat out on to the page.

The problem as I see it is when the application is installed for the first time, the Model is obviously empty as the application is completely fresh. At this point, I call a web service which successfully retrieves data. Once retrieved, I save the data and assign the data to the Model.

Although I assign the data to the model, the View doesn't update itself. I also noticed that the NotifyPropertyChanged code doesn't fire when doing:

App.ViewModel.Signs = results.Signs

The code for the Model looks like this:

public int ID
{
    get { return _id; }
    set
    {
        if (value != _id)
        {
            _id = value;
            NotifyPropertyChanged("ID");
        }
    }
}

The rest of the properties have the same notion, ie NotifyPropertyChanged("objectName"); .

When I relaunch the application, the information on the screen successfully appears. It is only when the application fires from beginning or when the user manually asks for the latest data that it fails to update the View/Page.xaml.

Any ideas what I could do to fix this?

也许您的NotifyPropertyChanged方法已损坏,或者Signs属性未正确调用该方法。

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