【问题标题】:Is it possible to use compiled binding (x:Bind) with Relative Source, Templated Parent是否可以将编译绑定 (x:Bind) 与相对源、模板化父项一起使用
【发布时间】:2015-09-03 09:38:24
【问题描述】:

我想做这样的事情是一种风格:

Value="{x:Bind MyCustomDependencyProp, RelativeSource={RelativeSource TemplatedParent}}"

这可能吗?有任何性能优势吗?

使用 TemplateBinding 似乎不起作用,使用自定义 DependencyProperty,如此处其他地方所述:https://stackoverflow.com/a/8657453

【问题讨论】:

    标签: dependency-properties uwp templatebinding compiled-bindings


    【解决方案1】:

    不支持RelativeSource(带有x:Bind),因此这种特殊情况是不可能的(至少目前是这样)。

    使用 TemplateBinding 或 standard 绑定到 TemplatedParent(如您所述)是解决方法。

    TemplateBinding 已经是 Binding 的an optimized version,所以根据这个Build 2015 session by Sam Spencer.,它应该不是什么大不了的事

    【讨论】:

    • 其实RelativeSource是支持的,只有Mode=FindAncestor不支持。
    • @JustinXL 当然 :) 但问题是关于使用 x:Bind 和 RelativeSource TemplatedParent
    • @JustinXL 是的,我进行了编辑以使我的意思更清楚。谢谢!
    • 感谢你们的精彩回复和cmets!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-15
    • 1970-01-01
    • 2015-08-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多