【发布时间】:2011-02-28 05:19:54
【问题描述】:
我在输出窗口中得到了这个:
System.Windows.Data 错误:4:找不到与引用'RelativeSource FindAncestor,AncestorType='System.Windows.Controls.ItemsControl',AncestorLevel='1''的绑定源。绑定表达式:路径=垂直内容对齐;数据项=空;目标元素是'ListBoxItem'(名称='');目标属性是“VerticalContentAlignment”(类型“VerticalAlignment”)
这是我的 XAML,运行时看起来正确
<GroupBox Header="Grant/Deny Report">
<ListBox ItemsSource="{Binding Converter={StaticResource MethodBinder}, ConverterParameter=GrantDeny, Mode=OneWay}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Label Content="{Binding Entity}"/>
<Label Content="{Binding HasPermission}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</GroupBox>
【问题讨论】: