简体   繁体   English

Windows Phone 8-绑定

[英]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. 我有一个WP8 Pivot应用程序,其中包含一个旨在自动绑定到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. 这是通过自动生成的NotfifyPropertyChanged代码完成的,我已NotfifyPropertyChanged代码分配给了出现在页面上的所有属性。

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. 我看到的问题是,首次安装应用程序时,由于应用程序是完全新鲜的,因此Model显然是空的。 At this point, I call a web service which successfully retrieves data. 此时,我将调用一个成功检索数据的Web服务。 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. 尽管我将数据分配给了模型,但是View不会自动更新。 I also noticed that the NotifyPropertyChanged code doesn't fire when doing: 我还注意到,这样做时NotifyPropertyChanged代码不会触发:

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"); 其余属性具有相同的概念,即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. 只有当应用程序从头启动时,或者当用户手动要求提供最新数据时,它才无法更新View / Page.xaml。

Any ideas what I could do to fix this? 有什么想法可以解决吗?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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