Gop*_*ope 14 data-binding winrt-xaml
有人知道XAML绑定中FindAncestor的"新方法"是什么吗?查看RelativeSourceMode(http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.data.relativesourcemode),只有用于引用self或TemplatedParent的选项.FindAncestor消失了.我想知道为什么以及使用FindAncestor解决的问题的典型解决方案是什么.
最好的问候Gope
Ome*_*viv 14
为什么它会丢失?不知道,但我怀疑除了"微软没有足够的时间及时实现所有功能"之外还有其他解释.
一个简单的解决方法是使用ElementName,如:
Binding={ ElementName=TheNameOfTheAncesor, Path=DataContext.TheViewModelProperyIWantToBindTo }
Run Code Online (Sandbox Code Playgroud)
要向祖先添加x:Name属性,您希望FindAncestor绑定指向:
<TextBlock x:Name="TheNameOfTheAncestor" />
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2822 次 |
| 最近记录: |