Binding DataStatebehavior with WPF

Oct 21, 2009 at 1:15 AM

I've been using these samples perfectly with SilverLight, but when I try to use the DataStateBehavior in WPF with a model assigned to the DataSource I get the following error:

System.Windows.Data Error: 1 : Cannot create default converter to perform 'one-way' conversions between types 'System.Boolean' and 'System.Windows.Data.Binding'. Consider using Converter property of Binding. BindingExpression:Path=HasTarget; DataItem='NodeWrapper' (HashCode=22933695); target element is 'DataStateBehavior' (HashCode=19947763); target property is 'Binding' (type 'Binding')
System.Windows.Data Error: 5 : Value produced by BindingExpression is not valid for target property.; Value='True' BindingExpression:Path=HasTarget; DataItem='NodeWrapper' (HashCode=22933695); target element is 'DataStateBehavior' (HashCode=19947763); target property is 'Binding' (type 'Binding')

The underlying property 'HasTarget' is of type bool (although I tried it as a string too), and binding this property to a TextBlock shows it correctly returns true/false.

The error seems to suggest it want to bind to a Binding property? Has anyone come across this before?

Cheers,
  Jason

Dec 16, 2009 at 11:06 AM

Same problem here.

Dec 17, 2009 at 2:04 PM

I've fixed it: the Binding property on DataStateBehavior is a DependencyProperty, and it appears that you can't have a DependencyProperty for the Binding type or it gets confused.

I changed it to a plain old field-backed property and it works fine in VS2010 Beta 2 targetting WPF 4.

Cheers,
Mark