I have an expander that has n contained elements (possibly other Expanders that also contain elements).
开发者_运维问答Now I want to programmatically bring a contained element into view - like with BringIntoView() for ScrollViewers. All Expanders that currently hide the element should expand.
My current idea is to subclass the Expander and make it react to an event that bubbles up from the contained element. But there may be a much easier way in WPF, right?
You can create an attached property to do that instead of subclassing the existing Expander class. This AP would be of type bool, and when sets to True on an expander register for the Expanded event. In the event handler, you can walk up the logical tree to grab the parent Expander and toogle is IsExpanded property.
精彩评论