views:

33

answers:

1

Hello,

I have created an attached behavior that is used to execute a Delegate of type Func<bool> when the behavior is invoked. Below is the dependancy property definition.

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

I have it working just as expected however in my XAML I get the following error, preventing the designer from loading.

Property 'SendToDetailBehavior' was not found or is not serializable for type 'SortableListView'

Below you will find the 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">

If I change the underlying type of the Dependancy Property to a bool for example, the error goes away.

As I said the attached behavior is working, only the designer blows up. I have looked for documentation on this and have come up empty. I am hoping someone here has some insight.

Thanks, BDN

A: 

Is this happening in VS 2008, 2010, or Expression Blend? The VS2008 designer is notoriously fragile. As far as fixing it, have you tried using a non-generic delegate type? Something like so:

public delegate bool SendToDetail();

And then your VM would expose a property of that delegate type instead of Func<bool>.

Abe Heidebrecht
I have not tired that. That is a fair suggestion I will give it a try in the morning. It is VS2008 sadly.
Brette.Net