【发布时间】:2011-04-09 19:31:21
【问题描述】:
我创建了一个附加行为,用于在调用行为时执行Func<bool> 类型的委托。下面是依赖属性定义。
public static readonly DependencyProperty SendToDetailBehaviorProperty = DependencyProperty.RegisterAttached("SendToDetailBehavior", typeof(Func<bool>), typeof(ListDetailAspectSendToDetailBehavior), new UIPropertyMetadata(null, SendToDetail));
我让它按预期工作,但是在我的 XAML 中出现以下错误,导致设计器无法加载。
属性“SendToDetailBehavior”原为 未找到或不可序列化 输入“SortableListView”
您将在下面找到 xaml。
<Controls:SortableListView Grid.Row="0"
Grid.Column="0"
Name="lvwLocations"
MinHeight="150"
MinWidth="{Binding Path=BusinessObject.Locations, ValidatesOnDataErrors=true, Converter={StaticResource AlwaysReturn1Converter}, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
Style="{DynamicResource SortableListViewStyle}"
ScrollViewer.VerticalScrollBarVisibility="Auto"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
IsSynchronizedWithCurrentItem="True"
**behaviors:ListDetailAspectSendToDetailBehavior.SendToDetailBehavior="{Binding Path=LocationListDetail.SendFocusToDetail}"**
ItemsSource="{Binding Path=LocationListDetail.MasterList}"
SelectedItem="{Binding Path=LocationListDetail.DetailItem, Mode=TwoWay}"
MouseDoubleClick="lvwLocations_MouseDoubleClick">
例如,如果我将依赖属性的基础类型更改为bool,错误就会消失。
正如我所说的附加行为是有效的,只有设计者爆炸了。我一直在寻找这方面的文档,但结果却是空的。我希望这里有人有一些见解。
谢谢, 宽带网
【问题讨论】:
标签: wpf dependency-properties attached-properties attachedbehaviors