I have developed a behavior that changes the Clip property of the AssociatedObject. When I run the application, all is well. But when I view the page in Blend it appears like the behavior does not affect its associated object.
I tried to “debug” blend by attaching visual studio 2010 debugger to it’s process and set a break point on the behavior’s OnAttached method, but the breakpoint is never reached. As if blend prevents that behavior from being attached at design time.
Is there a way around it?
Cheers,
I finally found a workable way around it, but there’s a big caveat which I put at the end of this answer. Here’s my CustomAttachManager:
You can then use it to attach behaviors like this:
My example behavior changes the background of a panel to red, which is visible in the designer.
The remaining problem is the case of multiple behaviors. The best solution I could come up with is a proxy:
which can be used this way:
The proxy has a defect in that it won’t properly handle behaviors added after something already got attached, but that is not going to happen in the classic use case.
The caveat is that I don’t know a way to make Blend display the behaviors in the object tree. The “AlternateContentProperty” can’t be used because it doesn’t work for attached properties, which is what CustomAttachManager uses.
I will update this answer should I find an answer to this problem.