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.
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>
-------------------------------------------------------------------------------------
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>
-------------------------------------------------------------------------------------