views:

311

answers:

1

I have made some custom attached properties that enable me to create a "pop out" effect on any control.

It animates the width and/or height when a boolean DependencyProperty is toggled.

Is there a good way to set all ScrollViewer's scrollbar visibility inside the control to hidden during this effect? You can see some ugly scrollbars appear during the animation.

I would rather not have to traverse the visual tree at the start of the animation, and then do it again when the animation completes.

EDIT: Although an alternate solution would be nice, at this point I'd rather bind to a readonly attached property named IsAnimating to handle setting the scroll visibility.

Is there a global way to to this?

+1  A: 

Instead of animating the width of the control itself, try fixing its width at the start of the animation and reparenting it into a grid, and animate the grid's width instead. The original visual wouldn't change size in its own little world, and no scroll bars would appear or change.

Aviad P.
I don't see how this would work. We need everything to scale or center appropriately (besides scrollbars). There are some centered controls, gradients, images, etc. that adjust according the the controls width.
Jonathan.Peppers
How about reparenting to a ViewBox instead then? That would just visually stretch everything without forcing a layout change.
Aviad P.
I think it may be simpler to create a readonly attached property named IsAnimating and bind to it. Is there a global way to turn off ScrollViewers? Otherwise I'll just setup the binding for each scrollviewer I need.
Jonathan.Peppers
I don't know if it would be simpler, you need to kep track of your scrollviewers, if one is added even indirectly through an control template that's part of the windows theme, you have to decompose it and attach your property. Anyway, reparenting is not complex either.
Aviad P.
I've actual done the templating to expose internal scrollviewers already anyways--I'm having to do things like create RoutedCommands to move the scrollviewer in a listbox, for example.
Jonathan.Peppers