NavigationBar and Expander template

Navigation for WPF Forum

Posted 14 years ago by Arthur Damen

I'm using the NavigationBar and add Expanders dynamically.
To arrange the Expanders in a specific order, I need to use the following part of VB code:
Dim ContentPresenter1 = TryCast(Me.Expander1.Template.FindName("ExpandSite", Expander1), ContentPresenter)
This works for Expanders with the default WPF style (in another default solution), but not for the ones that have the built-in style for the NavigationBar.
ContentPresenter1 will be Nothing/Null doing so.

So my question is: what's Actipro's approach to this?
Or more specifically: what's Actipro's equivalent template to the default "ExpandSite" that WPF is using?

Comments (3)

Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Hi Arthur,

If you are a WPF Studio customer then you can download the default Styles, which show the default templates, from our site. The following blog post describes this more:

But to answer your question, our styles for the Expander do not name the ContentPresenter. The native WPF Style give the ContentPresenter a name simply because they need to reference that element in one or more Triggers (which show or hide the ContentPresenter). Our Styles do not need to name the ContentPresenter, because we do not need to reference it from any triggers. Our Styles do, however, reference an instance of AnimatedExpanderDecorator which is used to show or hide the ContentPresenter.

Generally, you should not access elements by name unless they are explicitly named parts (i.e. they are prefixed with "PART_"). If you can explain better what you are trying to accomplish, we may be able to find an alternative solution.

If you absolutely need access to the ContentPresenter, you can modify our Styles and use those in your application.

Actipro Software Support

Posted 14 years ago by Arthur Damen
I'm trying to create an accordion effect for the Expanders in the pane from my NavigationBar as I don't know how many Expanders users will add in that very pane.
Zero (all collapsed) or one Expander will be expanded as the space left for the Expanders is as small as it is already.
Basically I'm trying to implement the code from the project found at:

This works like a charm in the project shown, but not when I try to implement this in the NavigationBar.
The code faults on the aforementioned line in trying to find the template.

If there's a better solution to it, then that's perfectly fine with me.
But at this moment I don't see how I need to adapt the code to get it to work with the NavigationBar.
If you could help me out with this, it would be greatly appreciated!
Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Hi Arthur,

To get that code working with our Styles, I believe you would just need to use "content" in place of "ExpandSite".

Normally, that type of control would be more "integrated". Such that there'd be a Panel that can arrange the Expanders, where the expanded one gets the remaining space (after arranging children). But the solution you are using should probably work just fine :-)

Actipro Software Support

The latest build of this product (v24.1.2) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.