我在我的输出窗口得到这个:WPF:我如何调试绑定错误?
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Controls.ItemsControl', AncestorLevel='1''. BindingExpression:Path=VerticalContentAlignment; DataItem=null; target element is 'ListBoxItem' (Name=''); target property is 'VerticalContentAlignment' (type '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>
给你的任务,不,没有和没有。唯一有趣的是ItemsSource是一个数据表。 – 2010-06-05 20:46:04
但是,嘿,至少你给了我足够的信息,知道它在样式表中。 – 2010-06-05 20:52:23