wpf - 在 WPF 中,什么是 TemplatedParent?

标签 wpf

我正在尝试了解 RelativeSource 绑定(bind),但找不到 TemplatedParent 的定义。
MSDN says:

"Gets a static value that is used to return a RelativeSource constructed for the TemplatedParent mode."



它没有出现在“Windows Presentation Foundation Unleashed”的索引中。

简单地说,什么是 TemplatedParent?

最佳答案

在 WPF 中,模板是用来构造类型树的。当创建该类型的新对象时,WPF 实质上会制作模板的副本。

因此,在模板内部,如果要引用新对象,请使用 TemplatedParent以便快速访问。否则,您将不得不使用 RelativeSource向上走树以找到父对象。

关于wpf - 在 WPF 中,什么是 TemplatedParent?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5294611/

相关文章:

WPF:标签的StringFormat问题

WPF 绑定(bind) MVVM 中验证装饰器的可见性

c# - 在 MainWindow 中更改 UserControl 的可见性

c# - 绑定(bind)到 WPF 中的 TreeView

c# - 扩展 Wpf MouseButtonEventArgs 以启用自定义参数

c# - Entity Framework -如何提高任何属性的OnChanging?

c# - 当我更改绑定(bind)页面属性时,为什么我在 wpf 中的主窗口没有更新?

wpf - 如何创建包含占位符以供以后使用的 WPF 用户控件

c# - 实现代码问题

c# - WPF WindowChrome : Edges of maximized Window are out of the screen