【问题标题】:Silverlight binding to page inside item templateSilverlight 绑定到项目模板内的页面
【发布时间】:2013-09-12 20:00:19
【问题描述】:

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

如您所见,我在行中有健全的代码 17-28 和 53-69。

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

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

【问题讨论】:

    标签: silverlight xaml data-binding


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-01-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-30
      • 2011-07-05
      • 2011-11-21
      相关资源
      最近更新 更多