Click here to Skip to main content
15,891,204 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I'm using Silverlight 5 and MVVM. I have a user control that I want to add a command to. I created a dependency property in the code behind of the control of type ICommand. But when I try to bind the command property to the command on my view model, I get an error saying that it "cannot convert binding expression to icommand".

VB
 Partial Public Class StringFilterControl
        Inherits UserControl
        Implements IFilteringControl

        Private col As GridViewBoundColumnBase
        Private textFilter As FilterDescriptor


        Public Sub New()
            InitializeComponent()
        End Sub

        Public Shared ReadOnly IsActiveProperty = 
           DependencyProperty.Register("IsActive",
           GetType(Boolean),
           GetType(StringFilterControl),                                                                             
           New System.Windows.PropertyMetadata(False))

        Public Property IsActive As Boolean Implements IFilteringControl.IsActive
            Get
                Return CBool(GetValue(IsActiveProperty))
            End Get
            Set(value As Boolean)
                SetValue(IsActiveProperty, value)
            End Set
        End Property


        Public Shared ReadOnly CallbackProperty = 
               DependencyProperty.Register("Callback",
               GetType(ICommand),
               GetType(StringFilterControl),
               New PropertyMetadata(Nothing))

        Public Property Callback As ICommand
            Get
                Return GetValue(CallbackProperty)
            End Get
            Set(value As ICommand)
                SetValue(CallbackProperty, value)
            End Set
        End Property
End Class
End Namespace



XML
<telerik:GridViewDataColumn.FilteringControl>
     <local:StringFilterControl Callback="{Binding FilterCommand}" />
</telerik:GridViewDataColumn.FilteringControl>
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900