NavigationBar in usercontrol minimize problem

Navigation for WPF Forum

Posted 15 years ago by John Babcock
I am using a NavigationBar in a UserControl. The user control is in my main window in a grid with a gridsplitter. The gridsplitter separates the NavigationBar from the main content.

Everything works fine until you move the gridsplitter. After that, when the NavigationBar is minimized the gridsplitter does not move and follow the NavigationBar.

Any Ideas what I could do to fix this? It works perfect if I use the NavigationBar directly in the main xaml window, but I am trying to keep the application modular so I want the NavigationBar to be in a separate control.



Sample Code:
<UserControl x:Name="userControl" x:Class="MainMenu.MyMainMenu"

<navigation:NavigationBar ContentWidth="160" MaxWidth="250" >
<navigation:NavigationPane Title="Main Menu">
<RowDefinition Height="Auto" />
<RowDefinition Height="1" />

<Expander Header="Menu1" IsExpanded="True" >

<Rectangle Grid.Row="1" Height="1" />

<Window x:Class="MainMenuTest.Window1"
Title="Window1" Height="400" Width="600">

<DockPanel x:Name="mainlayout">

<StatusBar x:Name="statusBar" DockPanel.Dock="Bottom" >
<TextBlock Name="statusText"/>

<Border x:Name="MainUI" DockPanel.Dock="Left" >
<Border >
<Grid Margin="5">
<ColumnDefinition Width="auto" MinWidth="10" MaxWidth="250" />
<ColumnDefinition Width="5" />
<ColumnDefinition Width="*" MinWidth="400" />

<mainmenu:MyMainMenu x:Name="mainMenu" />

<GridSplitter Grid.Column="1" ResizeDirection="Columns" ResizeBehavior="PreviousAndNext" Background="Transparent" Width="5" />

<Border Grid.Column="2" BorderThickness="1" Padding="5" BorderBrush="Gray">
<Label>Content Area</Label>


Comments (1)

Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Hi John,

This is an issue with how Microsoft designed Grid that we ran into when building samples as well.

We have some special code inside of NavigationBar to handle it when the NavigationBar is located within a Grid. That is why it works when in your main Window but not in the UserControl, because in that scenario it doesn't know that it's in a Grid any more.

Maybe instead of using a UserControl, just make your control be a NavigationBar directly. That would work around this and keep things modular.

Actipro Software Support

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

Add Comment

Please log in to a validated account to post comments.