O'Reilly logo

Microsoft® Silverlight® Edition: Programming Windows® Phone 7 by Charles Petzold

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Sharing Data Among Pages

Keep in mind that all the pages in your program have convenient access to the App class that derives from Application. The static Application.Current property returns the Application object associated with the program, and you can simply cast that to App. This means that you can use the App class for storing data you want to share among multiple pages of the application.

In the SilverlightShareData project, I defined a simple public property in the App class:

Example 6-10. Silverlight Project: SilverlightShareData File: App.xaml.cs (excerpt)

public partial class App : Application
{
    // public property for sharing data among pages
    public Color? SharedColor { set; get; }

    . . .

}

I defined this property of type nullable Color ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required