I created a custom behavior that exposes some custom dependency properties whose values change based on AssociatedObject. I am using these properties for binding in other objects. Conceptually, think of it like this:
At runtime, the value of the dep prop doesn't reflect in the binding. Debugging it, I see (certain identifiers changed to protect the innocent!):
System.Windows.Data Error: 40 : BindingExpression path error: 'CustomProp' property not found on 'object' ''String' (HashCode=82768885)'. BindingExpression:Path=CustomProp; DataItem='String' (HashCode=82768885); target element is 'Button' (Name=''); target property is 'ToolTip' (type 'Double')
Why is it saying "object" and "string"? In actual fact, the DP is of type Point (so the binding is to Cus开发者_Python百科tomProp.X). It's like the Behavior looks like a string, or the property type appears to be a string to the binding engine.
1) Is my scenario even possible (binding to a property on a behavior)? 2) Is my syntax right?
Thanks so much!
Doh! I had bad XAML. I was referencing the behavior using "Source" instead of "ElementName." Dumb user error!
It turns out that binding to a property of a behavior from another control is just fine.
精彩评论