本文整理汇总了C#中DependencyObject.GetAttachedProperty方法的典型用法代码示例。如果您正苦于以下问题:C# DependencyObject.GetAttachedProperty方法的具体用法?C# DependencyObject.GetAttachedProperty怎么用?C# DependencyObject.GetAttachedProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DependencyObject
的用法示例。
在下文中一共展示了DependencyObject.GetAttachedProperty方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetRightAttachedProperty_NoCreate
public static AbstractProperty GetRightAttachedProperty_NoCreate(DependencyObject targetObject)
{
return targetObject.GetAttachedProperty(RIGHT_ATTACHED_PROPERTY);
}
示例2: GetBottomAttachedProperty_NoCreate
public static AbstractProperty GetBottomAttachedProperty_NoCreate(DependencyObject targetObject)
{
return targetObject.GetAttachedProperty(BOTTOM_ATTACHED_PROPERTY);
}
示例3: GetStateSlotAttachedProperty
/// <summary>
/// Returns the attached property instance for the <c>WorkflowContext.StateSlot</c> property.
/// </summary>
/// <remarks>
/// <para>
/// If the <c>WorkflowContext.StateSlot</c> property is set to a context name for a UI element, that element and
/// all its children will save their state in the current MediaPortal 2 workflow navigation context in the context variable of
/// the given name when the current screen is quit and restore the state when the screen is reloaded for the same
/// workflow navigation context.
/// </para>
/// <para>
/// The usage is like this:
/// <example>
/// <code>
/// <ListView
/// xmlns:mp_special_workflow="clr-namespace:MediaPortal.UI.SkinEngine.SpecialElements.Workflow;assembly=SkinEngine"
/// ...
/// mp_special_workflow:WorkflowContext.StateSlot="MainMenu">
/// ...
/// </ListView>
/// </code>
/// </example>
/// </para>
/// </remarks>
/// <param name="targetObject">The object whose attached property should be returned.</param>
/// <returns>Attached <c>SaveState</c> property.</returns>
public static AbstractProperty GetStateSlotAttachedProperty(DependencyObject targetObject)
{
AbstractProperty result = targetObject.GetAttachedProperty(STATE_SLOT_ATTACHED_PROPERTY);
if (result != null)
return result;
result = targetObject.GetOrCreateAttachedProperty(STATE_SLOT_ATTACHED_PROPERTY, string.Empty);
IWorkflowManager workflowManager = ServiceRegistration.Get<IWorkflowManager>();
// We save the workflow navigation context at the time when this attached property is requested because that is the time when
// the navigation context is the right one for the current screen. At the time when the Screen.HIDE_EVENT is raised,
// the navigation context has already moved to the next state.
NavigationContext context = workflowManager.CurrentNavigationContext;
result.Attach((prop, oldVal) => OnStateSlotChanged(targetObject, context, (string) prop.GetValue()));
return result;
}