Silverlight绑定到项目模板中的页面

时间:2013-09-12 20:00:20

标签: silverlight xaml data-binding

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

正如你所看到的那样,我在行上有合理的代码 17-28 和53-69。

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

什么是干扰?为什么它首先起作用而且不能在第二个起作用

1 个答案:

答案 0 :(得分:0)

第二个问题是它在GridView的ItemTemplate中,因此它不再与“Page”相同namescope。您应该能够使用RelativeSource / FindAncestor绑定来解决这个问题:

DataContext="{Binding RelativeSource={RelativeSource 
    Mode=FindAncestor,AncestorType=extras:ExtendedPage,Path=RolesViewModel}"