3
Vote

DP of type binding does not find binding instance, but binding value. MS.Internal.Data.DynamicValueConverter (SL4)

description

When you migrate this project to support silverlight 4, you get a problem when using the BindingListener object. The propery Binding of type binding does not function because the MS.Internal.Data.DynamicValueConverter will use the value of the binding instead of the binding instance itself.
For example in the SetDataProperty and the Binding property. When you do something like this in XAML to set the Binding property like {Binding ViewModel.IsDragging, ElementName=ApplicationRoleUserControl, Mode=TwoWay} it will return the value of the binding. In this case it'll be the value True or False because the property ViewModel.IsDragging is a boolean.
The MS.Internal.Data.DynamicValueConverter will throw an error because it cannot convert "True" to a type of binding. All behaviors with the dependency properties of type binding will not work in silverlight 4.

file attachments

comments

AvdMeulen wrote Apr 27, 2010 at 9:35 AM

Inside SetDataProperty I changed the dependency property Binding to a regular CLR property which sets the this.listener.Binding property.
Now this action is working again!

public Binding Binding
{
get { return this.listener.Binding; }
set { this.listener.Binding = value; }
}


Also removed the static bindingproperty from the clase.

AvdMeulen wrote Apr 27, 2010 at 11:48 AM

For everybody who is using this with Silverlight 4, i've attached a ZIP file that has a working converted silverlight interactivity project inside.
I solved the discribed problem with what I've written about the binding.

Hopefully this will help the people who wants to use this for Silverlight 4!

wrote Apr 27, 2010 at 11:48 AM

wrote May 28, 2010 at 11:13 PM

sreekanthnitc wrote May 29, 2010 at 3:14 PM

Hi

We were using <InteractiveBehavior:DataStateBehavior Binding="{Binding Comment}" Value="{x:Null}" TrueState="AddState" FalseState="EditState" />this statement to change the text of a column in a grid if Comment field has data. This started failing after failing to SL 4. We used the code which was given in the attachment but still we are not able to fix the issue. Please provide us a sample to change the text based on the Above line.

Your help is higly appreciated.

Thanks,
Sreekanth.B

wrote Nov 8, 2010 at 12:45 PM

Kiener wrote Nov 11, 2010 at 8:43 AM

Sorry, I've hit the button too many times, because my browser was not responsive...

wrote Feb 21, 2013 at 10:49 PM