First of all, I'd like to say that I was looking for an answer for over 3 days now. Yes, I know that Binding can only be done to a DependencyProperty. In my project I use DependencyProperty in several places, from many different Libraries and in many different windows/UserControls. All works just fine. But in one specific class I just can't get rid of that error... What's Interesting, It's only VS complaining about this (not existing) problem, as the project compiles and works as expected (the only reason I investigate is that due to that error both the builder and the designer have problems with refreshing Interface). Here is the class (I found the example somewhere on the Internet):
Public Class BindingProxy
Inherits Freezable
Public Shared ReadOnly DataProperty As DependencyProperty = DependencyProperty.Register("Data", GetType(Object), GetType(BindingProxy), New UIPropertyMetadata(AddressOf MyPropertyChangedHandler))
Public Property Data As Object
Get
Return GetValue(DataProperty)
End Get
Set(value As Object)
SetValue(DataProperty, value)
End Set
End Property
Protected Overrides Function CreateInstanceCore() As Freezable
Return New BindingProxy
End Function
Public Shared Sub MyPropertyChangedHandler(ByVal target As DependencyObject, ByVal args As DependencyPropertyChangedEventArgs)
CType(target, BindingProxy).Data = args.NewValue
End Sub
End Class
And It's used like this (here tha "Data" property is underlined and the error is shown):
<helpers:BindingProxy x:Key="proxy" Data="{Binding}" />
The Purpose of this is to bind templated controls (Like Button in DataTemplate for ListViews ItemTemplate) to the main ViewModel:
<Button Command="{Binding Data.DoSomethingCommand, Source={StaticResource proxy}}" CommandParameter="{Binding ID}" />
The BindingProxy class resides in a different project (same solution). As I said, the program compiles and works as expected. It's just the UI refreshing during designing and debugging that drives me crazy that made me looking for an answer...
Thanks in Advance, Piotr Lemański.