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

隐身守侯 提交于 2019-11-28 07:37:15

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

There is no general solution for this lack afaik, for example you can't access ListViewItem properties in DataTemplate so you can't react on selection change elegantly. You should find workaround for each particular case until FindAncestor will be added(I can't believe that this absence is not just due to the lack of time)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!