Binding to a command issues...

Jul 22, 2009 at 7:29 PM

Hi,

First of all the premise of these Behaviours is excellent. The team and I have been waiting for this for a while. Now the issue...

When using the InvokeDataCommand bound to a View Model Command I get:

System.Windows.Data Error: 1 : Cannot create default converter to perform 'one-way' conversions between types 'Behaviours.UI.MainCommand' and 'System.Windows.Data.Binding'. Consider using Converter property of Binding. BindingExpression:Path=MainCommand; DataItem='MainViewModel' (HashCode=47422476); target element is 'InvokeDataCommand' (HashCode=44624228); target property is 'Command' (type 'Binding')

And then:

System.Windows.Data Error: 5 : Value produced by BindingExpression is not valid for target property.; Value='Behaviours.UI.MainCommand' BindingExpression:Path=MainCommand; DataItem='MainViewModel' (HashCode=47422476); target element is 'InvokeDataCommand' (HashCode=44624228); target property is 'Command' (type 'Binding')

I am assuming the second issue is caused by the first issue but I have not seen this in my data binding adventures so far. Could you tell me what am I missing here as I am doing what I have always done when using the Command property on the Button control. The XAML code follows:

        <Button Content="Button">
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="Click">
                    <si:InvokeDataCommand Command="{Binding MainCommand}" />                
                </i:EventTrigger>
            </i:Interaction.Triggers>
        </Button>  

Keep up the good work and we look forward to your reply!

Kind regards,

Adam

Jul 23, 2009 at 9:17 AM

On a side note the issue above is for WPF. The exact same code works fine in Silverlight.

Aug 6, 2009 at 12:25 PM

Hi,

I proposed a fix here: http://expressionblend.codeplex.com/WorkItem/View.aspx?WorkItemId=5335

and blogged about it here: http://blog.galasoft.ch/archive/2009/08/06/expression-blend-samples-invokedatacommand-bug.aspx

HTH,

Laurent