Files
docs-desktop/dotnet-desktop-guide/framework/wpf/app-development/persist-and-restore-application-scope-properties.md
T
Andy De George da363692ff Initial WPF content migrated (#17)
* Reset branch for WPF changes

* Convert BMP to PNG; fix link-out-of-scope err

* Add snippets for WPF... 6794 files!!!!

* Add missing snippets

* update file updated between migration

* Fix paths to include

* update breadcrumb and toc

* fix index links

* fix index links

* fix index links

* fix markdown
2020-09-04 09:46:28 -07:00

2.1 KiB

title, ms.date, dev_langs, helpviewer_keywords, ms.assetid
title ms.date dev_langs helpviewer_keywords ms.assetid
How to: Persist and Restore Application-Scope Properties Across Application Sessions 03/30/2017
csharp
vb
application-scope properties [WPF], persisting
persisting application-scope properties [WPF]
properties [WPF], persisting
restoring application-scope properties [WPF]
properties [WPF], restoring
application-scope properties [WPF], restoring
55d5904a-f444-4eb5-abd3-6bc74dd14226

How to: Persist and Restore Application-Scope Properties Across Application Sessions

This example shows how to persist application-scope properties when an application shuts down, and how to restore application-scope properties when an application is next launch.

Example

The application persists application-scope properties to, and restores them from, isolated storage. Isolated storage is a protected storage area that can safely be used by applications without file access permission. The App.xaml file defines the App_Startup method as the handler for the xref:System.Windows.Application.Startup?displayProperty=nameWithType event, and the App_Exit method as the handler for the xref:System.Windows.Application.Exit?displayProperty=nameWithType event, as shown in the highlighted lines of the first example. The second example shows a portion of the App.xaml.cs and App.xaml.vb files that highlights the code for the App_Startup method, which restores application-scope properties, and the App_Exit method, which saves application-scope properties.

[!code-xamlHOWTOApplicationModelSnippets#PersistRestoreAppScopePropertiesXAML1]

[!code-csharpHOWTOApplicationModelSnippets#PersistRestoreAppScopePropertiesCODEBEHIND1] [!code-vbHOWTOApplicationModelSnippets#PersistRestoreAppScopePropertiesCODEBEHIND1]