PhoneApplicationService.State Property

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Gets the dictionary used for passing an application’s state between invocations.

Namespace:  Microsoft.Phone.Shell
Assembly:  Microsoft.Phone (in Microsoft.Phone.dll)

Syntax

Public ReadOnly Property State As IDictionary(Of String, Object)
public IDictionary<string, Object> State { get; }

Property Value

Type: System.Collections.Generic..::.IDictionary<(Of <(String, Object>)>)
Type: IDictionary<(Of <(TKey, TValue>)>).

Exceptions

Exception Condition
InvalidOperationException

The State dictionary cannot be modified after the Deactivated event has been handled or before the Activated event has been raised.

ArgumentOutOfRangeException

Values placed in the State dictionary must be serializable. This exception is only thrown while debugging. At run time, this exception is silently ignored.

Remarks

Windows Phone applications are deactivated when the user navigates to another application. When the user returns to the application, by using the Back button or by completing a Launcher or Chooser task, the application is reactivated. An application can store transient application state in the State dictionary in the handler for the Deactivated event. In the Activated event handler, an application can use the values stored in the State dictionary to transient application state.

Version Information

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Platforms

Windows Phone

See Also

Reference

PhoneApplicationService Class

Microsoft.Phone.Shell Namespace