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

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

问题描述

有没有人知道XAML绑定中FindAncestor的新方法是什么?查看RelativeSourceMode( http://msdn.microsoft.com /en-us/library/windows/apps/windows.ui.xaml.data.relativesourcemode )只有参考自己或TemplatedParent的选项。 FindAncestor没了我想知道为什么以及使用FindAncestor修复的问题的典型解决方案是什么。



最好的问候
Gope

解决方案

为什么缺少?不知道,但我怀疑有一个解释,除了微软没有足够的时间实现所有的功能及时。



一个简单的解决方法是使用 ElementName ,如下所示:

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

另外,要为您想要的祖先添加一个 x:Name 属性FindAncestor绑定指向:

 < TextBlock x:Name =TheNameOfTheAncestor/> 


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.

Best regards Gope

解决方案

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".

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

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

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 missing?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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