0

我对绑定有奇怪的问题。请检查此要点 https://gist.github.com/anonymous/865b0848f61cfdf988a5

如您所见,我在第 17-28 和 53-69 行有正常的代码。

当第二个根本不起作用时,第一个就像一个魅力(它显示为 1 像素高度的红线)。

有什么区别?为什么它首先有效而第二次无效

4

1 回答 1

0

第二个的问题是它在 GridView 的ItemTemplate内,因此它不再与“Page”在同一个名称范围内。您应该可以通过使用RelativeSource / FindAncestor绑定来解决此问题:

DataContext="{Binding RelativeSource={RelativeSource 
    Mode=FindAncestor,AncestorType=extras:ExtendedPage,Path=RolesViewModel}"
于 2013-09-12T20:53:55.163 回答