Bound NavigationBar with ArePanesVisibile property

Navigation for WPF Forum

Posted 13 years ago by Aled Hughes - Principal Software Engineer, Control Techniques Ltd.
Version: 11.1.0545
Avatar
Hi,
I have a NavigationBar that gets its items via data binding (ItemsSource property is set to an IEnumerable collection and an ItemContainerStyle is defined) and I want it to hide the navigation pane buttons when there is only one item in the bound collection.
So I bound the ArePanesVisible property to a property in my view-model that returns true if there is more than one navigation item, false otherwise.

However, I find that the NavigationBar fails to show the single panel.

Here is the XAML code:
<navigation:NavigationBar Grid.Column="0"  Name="navigationBar1"
ItemsSource="{Binding NavigationItems}"
ArePanesVisible="{Binding MoreThanOneNavigationItem}"
IsTextSearchEnabled="False">
    <navigation:NavigationBar.ItemContainerStyle>
        <Style TargetType="{x:Type navigation:NavigationPane}">
            <Setter Property="Title" Value="{Binding Name}"/>
            <Setter Property="Content" Value="{Binding NavigationContent}"/>
            <Setter Property="ImageSourceLarge" Value="{Binding ImageUri}"/>
        </Style>
    </navigation:NavigationBar.ItemContainerStyle>
</navigation:NavigationBar>
If I set ArePanesVisible="False" rather than through a binding it still doesn't show the default pane. I also tried setting the SelectedItem property to the first item in the list.

I found the only way to get it to work was to set the ArePanesVisible property to false in the IsLoaded event (or later). Or if the navigation panes are explicitly set in XAML rather than through ItemsSource.

This seems to be a bit of a bug to me, or am I missing something?

(11.1.542.0)

ADDITION: I find that if I set the ArePanesVisible=false, collapse then expand the navigation control the hosted panel disappears and I get a "{DisconnectedItem}" text instead. Why is this? I don't really want to loose the ability to minimize it!

[Modified at 09/06/2011 07:06 AM]

Comments (3)

Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Aled,

The ArePanesVisible property is only used in the NavigationBar styles to control the visiblity of the splitter and items presenter. It shouldn't affect the display of the selected content.

If you can please put together a small sample project that reproduces your issue and email it over then we can take a closer look. Be sure to remove any executables or change the extension of the zip file to ensure it gets past our email filters.


Actipro Software Support

Posted 13 years ago by Aled Hughes - Principal Software Engineer, Control Techniques Ltd.
Avatar
I've emailed a small sample project.
Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Aled,

Thank you for the sample. The NavigationBar is an ItemsControl, much like a TabControl. Unlike the TabControl, the NavigationBar needs to get the container (i.e. NavigationPane) for the selected item for presentation. The issue is that when ArePanesVisible is set to false, the ItemsPresenter used by the NavigationBar is collapsed. Since the ItemsPresenter is collapsed, the containers are not generated so we have nothing to display.

I've updated the default Style/ControlTemplates to hide the ItemsPresenter instead of collapsing it so the containers will be generated and we can still present the content. This will be included in the next maintenance release.


Actipro Software Support

The latest build of this product (v24.1.1) 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.