本文整理汇总了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;
}