是否可以将已编译的绑定(x:Bind)与相对源,模板化父级一起使用 [英] Is it possible to use compiled binding (x:Bind) with Relative Source, Templated Parent

查看:64
本文介绍了是否可以将已编译的绑定(x:Bind)与相对源,模板化父级一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想做这样的事情:

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

这可能吗?有什么性能上的好处?

Is that possible? Are there any performance benefits?

使用TemplateBinding似乎不起作用,并且具有自定义DependencyProperty,如SO上其他地方所述: https://stackoverflow.com/a/8657453

Using TemplateBinding does not seem to work, with a custom DependencyProperty as described elsewhere here on SO: https://stackoverflow.com/a/8657453

推荐答案

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

RelativeSource (with x:Bind) is not supported, therefore this particular scenario won't be possible (at the moment, at least).

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

Using TemplateBinding or standard Binding to TemplatedParent (as you mentioned) are workarounds.

TemplateBinding已经优化版本绑定,因此根据此构建, Sam Spencer在2015年届会议上。

TemplateBinding is already an optimized version of Binding so it shouldn't be that big of a deal according to this Build 2015 session by Sam Spencer.

这篇关于是否可以将已编译的绑定(x:Bind)与相对源,模板化父级一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆