Question

NavigationBar Questions

Posted 2 months ago by Avatar Cory J. Geesaman

A couple questions in relation to events:

Is it possible to catch a click/tap of a NavigationBar button which has already been clicked (e.g. when the item is already selected in the view pane and no change is occurring?)  An alternative to this that would be better in my case would be if the selected button can be hidden outright such that it acts more like an Accordion control (e.g. expanding the active button into the view pane as it is with the header instead of having the header text plus button text duplicated and taking up space on screen.)

Tried crossing this out but strikethrough doesn't seem to want to work outside of the editor in Waterfox (based on Firefox.)  Is it possible to catch a click/tap of a NavigationBar header?  (I have a TreeListView inside of the NavigationBar - both are bound to the same data source and I'd like to be able to treat the node that acts as a category as a traversable node in itself by clearing the TreeListView selection and setting the selected item to a downstream content view to be the same source as the category item in the NavigationBar.) See follow-up comment for solution if you come across this searching for how to do it.

[Modified 1 month ago]


Comments (7)

Posted 2 months ago by Cory J. Geesaman

For anyone that comes across this searching for how to do it, the second question was able to be resolved in my case with:

    <navigation:NavigationBar.ItemTemplate>
        <DataTemplate>
            <StackPanel x:Name="spAccordionHeader" Orientation="Horizontal" MouseDown="spAccordionHeader_OnMouseDown">
                <Image Margin="4" Source="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=navigation:NavigationBar}, Path=SelectedItem.LargeIcon}" />
                <TextBlock Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=navigation:NavigationBar}, Path=SelectedItem.Title}" />
            </StackPanel>
        </DataTemplate>
    </navigation:NavigationBar.ItemTemplate>
Posted 2 months ago by Actipro Software Support - Cleveland, OH, USA

Hi Cory,

1) The buttons for the panes execute the NavigationBarCommands.SelectPane command when clicked.  The NavigationBar control has a method that watches for and handles those commands.  It only changes the selection though. 

You can probably watch for button click events on the navigation bar in general like:

navBar.AddHandler(Button.ClickEvent, new RoutedEventHandler(OnButtonClick));

There isn't a way to hide the selected pane button though.

2) There isn't an event for a NavigationBarHeader click but that is a control in itself.  You could probably use another AddHandler to watch for some mouse events that occur within a NavigationBarHeader.


Actipro Software Support
Posted 2 months ago by Cory J. Geesaman

Is it possible to hide the actively selected button outright?  Just spotted the line where you already answered this, sorry.  Would it be possible to have that ability added?  Something akin to an AccordionMode flag would be the simplest from a user standpoint I think (since that's really the only thing missing from it being a true Accordion.)

Also, on a side note: I'm not sure if you're viewing this in a browser or not but I used strikethrough over the font after posting the solution to that second question in the original post, the strikethrough doesn't show up for me outside of the editor though (using Waterfox, a Firefox derivitive.)

[Modified 2 months ago]

Posted 2 months ago by Actipro Software Support - Cleveland, OH, USA

Hi Cory,

I'm not sure we want to get into hiding the selected pane button because I can foresee that leading to some usability issues with focus, layout, etc.  If you absolutely need to do it, you might be able to restyle the NavigationPane control to add support for that in its template via a trigger on the attached Selector.IsSelected property.

Thanks for the heads up on the forum strike-through not working.  We fixed that now.


Actipro Software Support
Posted 1 month ago by Cory J. Geesaman

Where would I need to point the trigger at to hide the button?

Posted 1 month ago by Actipro Software Support - Cleveland, OH, USA

Hi Cory,

You'd probably add this trigger to the NavigationPane Style:

<Trigger Property="Selector.IsSelected" Value="True">
	<Setter Property="Visibility" Value="Collapsed" />
</Trigger>

Actipro Software Support
Posted 1 month ago by Cory J. Geesaman

Thanks, this worked perfectly.

Information The latest build of this product (2018.1 build 0674) was released 5 days ago, which was after the last post in this thread.

Add a Comment

Please log in to a validated account to post comments.