NavigationBar in usercontrol minimize problem

Navigation for WPF Forum

Posted 15 years ago by John Babcock
Avatar
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.

Thanks

-JB

Sample Code:
-------------------------------------------------------------------------------------
<UserControl x:Name="userControl" x:Class="MainMenu.MyMainMenu"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:navigation="http://schemas.actiprosoftware.com/winfx/xaml/navigation"
xmlns:mainmenu="clr-namespace:MainMenu"
>

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

<Expander Header="Menu1" IsExpanded="True" >
<ListBox>
<ListBoxItem>Choice1</ListBoxItem>
</ListBox>
</Expander>

<Rectangle Grid.Row="1" Height="1" />
</Grid>
</navigation:NavigationPane>

</navigation:NavigationBar>
</UserControl>
-------------------------------------------------------------------------------------
<Window x:Class="MainMenuTest.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mainmenu="clr-namespace:MainMenu"
Title="Window1" Height="400" Width="600">

<DockPanel x:Name="mainlayout">

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

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

<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>
</Border>
</Grid>
</Border>

</Border>
</DockPanel>
</Window>
-------------------------------------------------------------------------------------

Comments (1)

Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
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.1) 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.