WinRT (Win 8) Store App XAML Bindings RelativeSourceMode FindAncestor 丢失? [英] WinRT (Win 8) Store App XAML Bindings RelativeSourceMode FindAncestor missing?

查看:18
本文介绍了WinRT (Win 8) Store App XAML Bindings RelativeSourceMode FindAncestor 丢失?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道 XAML 绑定中 FindAncestor 的新方法"是什么吗?查看 RelativeSourceMode (http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.data.relativesourcemode) 只剩下用于引用 self 或 TemplatedParent 的选项了.FindAncestor 不见了.我想知道我使用 FindAncestor 修复的问题的原因和典型解决方案是什么.

does anybody know what the "new way" of FindAncestor in XAML bindings is? Looking at the RelativeSourceMode (http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.data.relativesourcemode) there are only options left for referencing self or the TemplatedParent. FindAncestor is gone. I'd like to know why and what are the typical solutions to the problems I fixed using FindAncestor.

最好的问候戈普

推荐答案

为什么它不见了?不知道,但我怀疑除了微软没有足够的时间及时实现所有功能"之外,还有其他解释.

Why it's missing? No idea, but I doubt there's an explanation other than "Microsoft did not have enough time to implement all the features in time".

一个简单的解决方法是使用 ElementName 代替,如:

An easy work-around is to use ElementName instead, as in:

Binding={ ElementName=TheNameOfTheAncesor, Path=DataContext.TheViewModelProperyIWantToBindTo }

并向您希望 FindAncestor 绑定指向的祖先添加 x:Name 属性:

And to add an x:Name attribute to the ancestor you wanted your FindAncestor binding to point to:

<TextBlock x:Name="TheNameOfTheAncestor" />

这篇关于WinRT (Win 8) Store App XAML Bindings RelativeSourceMode FindAncestor 丢失?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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