dependency-properties - 是否可以使用已编译的绑定(bind) (x :Bind) with Relative Source, Templated Parent

标签 dependency-properties uwp templatebinding compiled-bindings

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

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

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

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

最佳答案

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

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

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

关于dependency-properties - 是否可以使用已编译的绑定(bind) (x :Bind) with Relative Source, Templated Parent,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32372073/

相关文章:

c# - 如何在不使用 MVVM 的情况下绑定(bind) DependencyProperty

c# - 将依赖属性 (View) 与属性 (ViewModel) 同步

python - python中的属性装饰器初始化

xaml - 何时在 UserControl 上使用模板化控件?

c# - 在两种方法之间来回传递参数 C#

silverlight - 如何在自定义控件中的数据模板内使用模板绑定(bind)(Silverlight)

c# - 当依赖项依赖的变量或字段发生更改时更新依赖项属性

javascript - Quickblox 通过 Raspberry Pi 3 上的 UWP 应用程序

WPF 自定义控件 : TemplateBinding to Image

c# - 如何在触发器运行时重新计算 WPF 资源?