1
我什至不知道如何表达这一点,所以即时通讯非常抱歉,如果标题是混乱。我的XAML(简体)看起来是这样的:绑定在一个曾孙上的属性,以祖先
<UserControl x:Class="PBA.Application.Client.UserControls.UserControls.FreqReserve.OverView" xmlns:FreqReserve="clr-namespace:PBA.Application.Client.UserControls.UserControls.FreqReserve">
...
<DockPanel>
<UserControls:LegendControl>
<UserControls:LegendControl.Items>
<UserControls:LegendItem Visibility="{Binding Path=IsDirtyVisible, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type FreqReserve:OverView}}, Converter={StaticResource btvc}}" Identifier="Pink" Text="Ikke sendt"></UserControls:LegendItem>
<UserControls:LegendItem Identifier="Yellow" Text="Sendt"></UserControls:LegendItem>
<UserControls:LegendItem Identifier="LightGreen" Text="Accepteret"></UserControls:LegendItem>
<UserControls:LegendItem Identifier="White" Text="Ikke accepteret"></UserControls:LegendItem>
</UserControls:LegendControl.Items>
</UserControls:LegendControl>
</DockPanel>
</UserControl>
其中LegendItem列表模板化在legendcontrol中。
绑定表达式失败,出现System.Windows.Data错误:4.我尝试过使用elementname,而使用相同的结果。我猜这与LegendItems有些关系,并不直接在Visual树中,但我不知道(WPF菜鸟,我知道)。我究竟做错了什么?
对不起。在去除绒毛的时候稍微过了一会儿,并且用手写了一段代码,因为它不再是实际的代码。代码段已更新以更好地反映实际代码。 – hhravn 2010-10-13 13:51:30
让我们从简单的开始,并努力解决问题。 IsDirtyVisible是OverView控件的属性吗? – 2010-10-13 14:14:45
是的,它是一个包装的依赖属性。 – hhravn 2010-10-13 14:47:51