这是基于 XAML 的应用程序 (WPF/Silverlight/WinRT) 中的常见情况。
WPF 相关链接 -> WPF Databinding: How do I access the "parent" data context?RelativeSource
与 AncestorType
, 和 Mode=FindAncestor
通常会在 WPF 中进行救援。
WinRT API 中缺少这两者。如何访问 parent 的(可能不是直接的),DataContext
?
(我知道 TemplateBinding
和 ElementBinding
但两者都不适合在 DataTemplate 中使用)。
最佳答案
我只是有同样的问题。大概这很常见??
这是一个有效的粗略解决方案:
<Grid Name="gridTop" Tag="{Binding}" />
{Binding Tag.SomeProp, ElementName=gridTop}
关于wpf - 如何在 Windows 8 商店应用程序中访问 Parent 的 DataContext,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15366609/