小编Bre*_*Net的帖子

类型委托的DependencyProperty

我创建了一个附加行为,用于在Func<bool>调用行为时执行类型委托.以下是依赖属性定义.

public static readonly DependencyProperty SendToDetailBehaviorProperty = DependencyProperty.RegisterAttached("SendToDetailBehavior", typeof(Func<bool>), typeof(ListDetailAspectSendToDetailBehavior), new UIPropertyMetadata(null, SendToDetail));
Run Code Online (Sandbox Code Playgroud)

我有它按预期工作但是在我的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">
Run Code Online (Sandbox Code Playgroud)

例如,如果我将Dependancy属性的基础类型更改bool为,则错误消失.

正如我所说的附加行为正在起作用,只有设计师才会爆炸.我已经找到了关于这方面的文档并且空洞了.我希望有人在这里有一些见解.

谢谢,BDN

wpf dependency-properties attachedbehaviors attached-properties

6
推荐指数
1
解决办法
3285
查看次数