本文整理匯總了C#中Windows.UI.Xaml.Controls.Frame.SetValue方法的典型用法代碼示例。如果您正苦於以下問題:C# Frame.SetValue方法的具體用法?C# Frame.SetValue怎麽用?C# Frame.SetValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Windows.UI.Xaml.Controls.Frame
的用法示例。
在下文中一共展示了Frame.SetValue方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: RegisterFrame
/// <summary>
/// Registers a <see cref="Frame"/> instance to allow its navigation history to be saved to
/// and restored from <see cref="SessionState"/>. Frames should be registered once
/// immediately after creation if they will participate in session state management. Upon
/// registration if state has already been restored for the specified key
/// the navigation history will immediately be restored. Subsequent invocations of
/// <see cref="RestoreAsync"/> will also restore navigation history.
/// </summary>
/// <param name="frame">An instance whose navigation history should be managed by
/// <see cref="SuspensionManager"/></param>
/// <param name="sessionStateKey">A unique key into <see cref="SessionState"/> used to
/// store navigation-related information.</param>
/// <param name="sessionBaseKey">An optional key that identifies the type of session.
/// This can be used to distinguish between multiple application launch scenarios.</param>
public static void RegisterFrame(Frame frame, String sessionStateKey, String sessionBaseKey = null)
{
if (frame.GetValue(FrameSessionStateKeyProperty) != null)
{
throw new InvalidOperationException("Frames can only be registered to one session state key");
}
if (frame.GetValue(FrameSessionStateProperty) != null)
{
throw new InvalidOperationException("Frames must be either be registered before accessing frame session state, or not registered at all");
}
if (!string.IsNullOrEmpty(sessionBaseKey))
{
frame.SetValue(FrameSessionBaseKeyProperty, sessionBaseKey);
sessionStateKey = sessionBaseKey + "_" + sessionStateKey;
}
// Use a dependency property to associate the session key with a frame, and keep a list of frames whose
// navigation state should be managed
frame.SetValue(FrameSessionStateKeyProperty, sessionStateKey);
_registeredFrames.Add(new WeakReference<Frame>(frame));
// Check to see if navigation state can be restored
RestoreFrameNavigationState(frame);
}
示例2: SessionStateForFrame
/// <summary>
/// Provides storage for session state associated with the specified <see cref="Frame"/>.
/// Frames that have been previously registered with RegisterFrame have
/// their session state saved and restored automatically as a part of the global
/// SessionState. Frames that are not registered have transient state
/// that can still be useful when restoring pages that have been discarded from the
/// navigation cache.
/// </summary>
/// <remarks>Apps may choose to rely on <see cref="LayoutAwarePage"/> to manage
/// page-specific state instead of working with frame session state directly.</remarks>
/// <param name="frame">The instance for which session state is desired.</param>
/// <returns>A collection of state subject to the same serialization mechanism as
/// SessionState.</returns>
public static Dictionary<String, Object> SessionStateForFrame(Frame frame)
{
var frameState = (Dictionary<String, Object>)frame.GetValue(FrameSessionStateProperty);
if (frameState == null)
{
var frameSessionKey = (String)frame.GetValue(FrameSessionStateKeyProperty);
if (frameSessionKey != null)
{
// Registered frames reflect the corresponding session state
if (!SessionState.ContainsKey(frameSessionKey))
{
SessionState[frameSessionKey] = new Dictionary<String, Object>();
}
frameState = (Dictionary<String, Object>)SessionState[frameSessionKey];
}
else
{
// Frames that aren't registered have transient state
frameState = new Dictionary<String, Object>();
}
frame.SetValue(FrameSessionStateProperty, frameState);
}
return frameState;
}
示例3: RegisterFrame
public static void RegisterFrame(Frame frame, string sessionStateKey, string sessionBaseKey = null)
{
if (frame.GetValue(FrameSessionStateKeyProperty) != null)
{
throw new InvalidOperationException("Frames can only be registered to one session state key");
}
if (frame.GetValue(FrameSessionStateProperty) != null)
{
throw new InvalidOperationException("Frames must be either be registerd before accessing frame session staet, or not registered at all");
}
if (!string.IsNullOrEmpty(sessionBaseKey))
{
frame.SetValue(FrameSessionBaseKeyProperty, sessionBaseKey);
sessionStateKey = sessionStateKey + "_" + sessionStateKey;
}
frame.SetValue(FrameSessionStateKeyProperty, sessionStateKey);
_registeredFrames.Add(new WeakReference<Frame>(frame));
RestoreFrameNavigationState(frame);
}
示例4: SessionStateForFrame
/// <summary>
/// 為與指定的 <see cref="Frame"/> 相關聯的會話狀態提供存儲。
/// 之前已向 <see cref="RegisterFrame"/> 注冊的框架已自動
/// 保存其會話狀態且還原為全局
/// <see cref="SessionState"/> 的一部分。 未注冊的框架具有
/// 在還原已從導航緩存中丟棄的頁麵時仍然有用的
/// 導航緩存。
/// </summary>
/// <remarks>應用程序可能決定依靠 <see cref="NavigationHelper"/> 管理
/// 特定於頁麵的狀態,而非直接使用框架會話狀態。</remarks>
/// <param name="frame">需要會話狀態的實例。</param>
/// <returns>狀態集合受限於與
/// <see cref="SessionState"/>。</returns>
public static Dictionary<String, Object> SessionStateForFrame(Frame frame)
{
var frameState = (Dictionary<String, Object>)frame.GetValue(FrameSessionStateProperty);
if (frameState == null)
{
var frameSessionKey = (String)frame.GetValue(FrameSessionStateKeyProperty);
if (frameSessionKey != null)
{
// 已注冊框架反映相應的會話狀態
if (!_sessionState.ContainsKey(frameSessionKey))
{
_sessionState[frameSessionKey] = new Dictionary<String, Object>();
}
frameState = (Dictionary<String, Object>)_sessionState[frameSessionKey];
}
else
{
// 未注冊框架具有瞬時狀態
frameState = new Dictionary<String, Object>();
}
frame.SetValue(FrameSessionStateProperty, frameState);
}
return frameState;
}
示例5: RegisterFrame
/// <summary>
/// 注冊 <see cref="Frame"/> 實例以允許將其導航曆史記錄保存到
/// <see cref="SessionState"/> 並從中還原。如果框架將參與會話狀態管理,
/// 則應在創建框架後立即注冊。在
/// 注冊時,如果已還原指定鍵的狀態,
/// 則將立即還原導航曆史記錄。
/// <see cref="RestoreAsync"/> 還將還原導航曆史記錄。
/// </summary>
/// <param name="frame">其導航曆史記錄應由
/// <see cref="SuspensionManager"/></param>
/// <param name="sessionStateKey"><see cref="SessionState"/> 的唯一鍵,用於
/// 存儲與導航相關的信息。</param>
public static void RegisterFrame(Frame frame, String sessionStateKey)
{
if (frame.GetValue(FrameSessionStateKeyProperty) != null)
{
throw new InvalidOperationException("Frames can only be registered to one session state key");
}
if (frame.GetValue(FrameSessionStateProperty) != null)
{
throw new InvalidOperationException("Frames must be either be registered before accessing frame session state, or not registered at all");
}
// 使用依賴項屬性可會話鍵與框架相關聯,並記錄其
// 導航狀態應托管的框架
frame.SetValue(FrameSessionStateKeyProperty, sessionStateKey);
_registeredFrames.Add(new WeakReference<Frame>(frame));
// 查看導航狀態是否可還原
RestoreFrameNavigationState(frame);
}
示例6: SessionStateForFrame
/// <summary>
/// Provides storage for session state associated with the specified <see cref="Frame"/>.
/// Frames that have been previously registered with <see cref="RegisterFrame"/> have
/// their session state saved and restored automatically as a part of the global
/// <see cref="SessionState"/>. Frames that are not registered have transient state
/// that can still be useful when restoring pages that have been discarded from the
/// navigation cache.
/// </summary>
/// <remarks>Apps may choose to rely on <see cref="NavigationHelper"/> to manage
/// page-specific state instead of working with frame session state directly.</remarks>
/// <param name="frame">The instance for which session state is desired.</param>
/// <returns>A collection of state subject to the same serialization mechanism as
/// <see cref="SessionState"/>.</returns>
public static Dictionary<String, Object> SessionStateForFrame(Frame frame)
{
var frameState = (Dictionary<String, Object>)frame.GetValue(FrameSessionStateProperty);
if (frameState == null)
{
var frameSessionKey = (String)frame.GetValue(FrameSessionStateKeyProperty);
if (frameSessionKey != null)
{
// Registered frames reflect the corresponding session state
if (!_sessionState.ContainsKey(frameSessionKey))
_sessionState[frameSessionKey] = Json.Instance.Serialize(new Dictionary<String, Object>());
frameState = Json.Instance.Deserialize<Dictionary<String, Object>>(_sessionState[frameSessionKey].ToString());
//frameState = (Dictionary<String, Object>);
}
else
{
// Frames that aren't registered have transient state
frameState = new Dictionary<String, Object>();
}
frame.SetValue(FrameSessionStateProperty, frameState);
}
return frameState;
}
示例7: RegisterFrame
/// <summary>
/// Registriert eine <see cref="Frame"/>-Instanz, um den zugehörigen Navigationsverlauf mithilfe von
/// <see cref="SessionState"/> speichern und wiederherstellen zu können. Rahmen sollten direkt nach der Erstellung
/// registriert werden, wenn diese Bestandteil der Verwaltung des Sitzungszustands sind. Wenn der
/// Zustand für den speziellen Schlüssel bereits wiederhergestellt wurde,
/// wird der Navigationsverlauf bei der Registrierung sofort wiederhergestellt. Bei nachfolgenden Aufrufen von
/// <see cref="RestoreAsync"/> wird der Navigationsverlauf ebenfalls wiederhergestellt.
/// </summary>
/// <param name="frame">Eine Instanz, deren Navigationsverlauf von
/// <see cref="SuspensionManager"/></param>
/// <param name="sessionStateKey">Ein eindeutiger Schlüssel in <see cref="SessionState"/> zum
/// Speichern von navigationsbezogenen Informationen.</param>
/// <param name="sessionBaseKey">Ein optionaler Schlüssel zum Identifizieren des Typs der Sitzung.
/// Damit können verschiedene Szenarien für den Anwendungsstart unterschieden werden.</param>
public static void RegisterFrame(Frame frame, String sessionStateKey, String sessionBaseKey = null)
{
if (frame.GetValue(FrameSessionStateKeyProperty) != null)
{
throw new InvalidOperationException("Frames can only be registered to one session state key");
}
if (frame.GetValue(FrameSessionStateProperty) != null)
{
throw new InvalidOperationException("Frames must be either be registered before accessing frame session state, or not registered at all");
}
if (!string.IsNullOrEmpty(sessionBaseKey))
{
frame.SetValue(FrameSessionBaseKeyProperty, sessionBaseKey);
sessionStateKey = sessionBaseKey + "_" + sessionStateKey;
}
// Eine Abhängigkeitseigenschaft verwenden, um den Sitzungsschlüssel mit einem Rahmen zu verknüpfen, und eine Liste von Rahmen speichern, deren
// Navigationszustand verwaltet werden soll
frame.SetValue(FrameSessionStateKeyProperty, sessionStateKey);
_registeredFrames.Add(new WeakReference<Frame>(frame));
// Überprüfen, ob der Navigationszustand wiederhergestellt werden kann
RestoreFrameNavigationState(frame);
}
示例8: SessionStateForFrame
public static Dictionary<string, object> SessionStateForFrame(Frame frame)
{
var frameState = (Dictionary<string, object>)frame.GetValue(mFrameSessionStateProperty);
if (frameState == null)
{
var frameSessionKey = (string)frame.GetValue(mFrameSessionStateKeyProperty);
if (frameSessionKey != null)
{
if (!mSessionState.ContainsKey(frameSessionKey))
{
mSessionState[frameSessionKey] = new Dictionary<string, object>();
}
frameState = (Dictionary<string, object>)mSessionState[frameSessionKey];
}
else
{
frameState = new Dictionary<string, object>();
}
frame.SetValue(mFrameSessionStateProperty, frameState);
}
return frameState;
}
示例9: SessionStateForFrame
/// <summary>
/// Bietet Speichermöglichkeit für den Sitzungszustand, der mit dem angegebenen <see cref="Frame"/> verknüpft ist.
/// Für Rahmen, die zuvor mit <see cref="RegisterFrame"/> registriert wurden, wird der
/// Sitzungszustand automatisch als Teil des globalen <see cref="SessionState"/>
/// gespeichert und wiederhergestellt. Rahmen, die nicht registriert sind, verfügen über einen vorübergehenden Zustand,
/// der weiterhin nützlich sein kann, wenn Seiten wiederhergestellt werden, die aus dem
/// im Navigationscache verworfen wird.
/// </summary>
/// <remarks>Apps können beim Verwalten des seitenspezifischen Zustands auf <see cref="NavigationHelper"/> zurückgreifen,
/// anstatt direkt mit dem Rahmensitzungszustand zu arbeiten.</remarks>
/// <param name="frame">Die Instanz, für die der Sitzungszustand gewünscht wird.</param>
/// <returns>Eine Auflistung des Zustands, für den der gleiche Serialisierungsmechanismus wie für
/// <see cref="SessionState"/>.</returns>
public static Dictionary<String, Object> SessionStateForFrame(Frame frame)
{
var frameState = (Dictionary<String, Object>)frame.GetValue(FrameSessionStateProperty);
if (frameState == null)
{
var frameSessionKey = (String)frame.GetValue(FrameSessionStateKeyProperty);
if (frameSessionKey != null)
{
// Registrierte Rahmen geben den entsprechenden Sitzungszustand wieder.
if (!_sessionState.ContainsKey(frameSessionKey))
{
_sessionState[frameSessionKey] = new Dictionary<String, Object>();
}
frameState = (Dictionary<String, Object>)_sessionState[frameSessionKey];
}
else
{
// Rahmen, die nicht registriert sind, verfügen über einen vorübergehenden Zustand
frameState = new Dictionary<String, Object>();
}
frame.SetValue(FrameSessionStateProperty, frameState);
}
return frameState;
}