开发者

Expand WPF Expander to bring contained element into view

开发者 https://www.devze.com 2022-12-09 10:55 出处:网络
I have an expander that has n contained elements (possibly other Expanders that also contain elements).

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消