Need help with this control alignment issue
-
I'm almost bald from pulling my hair out over this bug. I have a WPF window which as a section defined as follows:
<StackPanel Name="stackPaneln" Orientation="Horizontal" Margin="-1,29,0,54"> <DockPanel Name="navigation" > <StackPanel Name="stackPanel1" Width="162" HorizontalAlignment="Left" Height="486"> <Button Height="103" Name="configurationViewerRequest" Width="120" Margin="0,5" Click="configurationViewerRequest\_Click"> <StackPanel Orientation="Vertical"> <Image Source="Configuration\_icon\_by\_obsilion.png" Height="73" /> <TextBlock Text="Configuration" TextAlignment="Center" Margin="0,5,0,0" /> </StackPanel> </Button> <Button Height="100" Name="systemStatus" Width="120" Margin="0,5" Click="systemStatus\_Click"> <StackPanel Orientation="Vertical"> <Image Source="SystemMonitor.png" Height="73" /> <TextBlock Text="System Status" TextAlignment="Center" Margin="0,5,0,0" /> </StackPanel> </Button> <Button Height="103" Name="systemMonitor" Width="120" Margin="0,5" Click="systemMonitor\_Click"> <StackPanel Orientation="Vertical"> <Image Source="ViewInfo.png" Height="73" /> <TextBlock Text="System Monitor" TextAlignment="Center" Margin="0,5,0,0" /> </StackPanel> </Button> </StackPanel> </DockPanel> <DockPanel Name="destination" Margin="10,0,0,0" Width="608"> </DockPanel> </StackPanel>
The problem: When one of the buttons in the Navigation panel is clicked, the user control that provides the functionality is loaded into the 'destination' dock panel. So I have a user control which has a treeview and an editor window. In the editor window I put a label with content = '<----the navigation of over there' When the configuration button is clicked I create an instance of the editor, and do destination.Children.Add(controlEditor); Problem: the control is shifted all the way to the right of the window (aligned with x=0 of the Window!!! instead of the DockPanel!!!! Here is the xaml of the control I'm loading in case I screwed up there....
<UserControl x:Class="SnmpBrowser.ConfigurationManager"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compa -
I'm almost bald from pulling my hair out over this bug. I have a WPF window which as a section defined as follows:
<StackPanel Name="stackPaneln" Orientation="Horizontal" Margin="-1,29,0,54"> <DockPanel Name="navigation" > <StackPanel Name="stackPanel1" Width="162" HorizontalAlignment="Left" Height="486"> <Button Height="103" Name="configurationViewerRequest" Width="120" Margin="0,5" Click="configurationViewerRequest\_Click"> <StackPanel Orientation="Vertical"> <Image Source="Configuration\_icon\_by\_obsilion.png" Height="73" /> <TextBlock Text="Configuration" TextAlignment="Center" Margin="0,5,0,0" /> </StackPanel> </Button> <Button Height="100" Name="systemStatus" Width="120" Margin="0,5" Click="systemStatus\_Click"> <StackPanel Orientation="Vertical"> <Image Source="SystemMonitor.png" Height="73" /> <TextBlock Text="System Status" TextAlignment="Center" Margin="0,5,0,0" /> </StackPanel> </Button> <Button Height="103" Name="systemMonitor" Width="120" Margin="0,5" Click="systemMonitor\_Click"> <StackPanel Orientation="Vertical"> <Image Source="ViewInfo.png" Height="73" /> <TextBlock Text="System Monitor" TextAlignment="Center" Margin="0,5,0,0" /> </StackPanel> </Button> </StackPanel> </DockPanel> <DockPanel Name="destination" Margin="10,0,0,0" Width="608"> </DockPanel> </StackPanel>
The problem: When one of the buttons in the Navigation panel is clicked, the user control that provides the functionality is loaded into the 'destination' dock panel. So I have a user control which has a treeview and an editor window. In the editor window I put a label with content = '<----the navigation of over there' When the configuration button is clicked I create an instance of the editor, and do destination.Children.Add(controlEditor); Problem: the control is shifted all the way to the right of the window (aligned with x=0 of the Window!!! instead of the DockPanel!!!! Here is the xaml of the control I'm loading in case I screwed up there....
<UserControl x:Class="SnmpBrowser.ConfigurationManager"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compaAfter doing a few more tests it turns out that the work area was 600x400 but the user control was 600x800. After resizing the user control to the area of the dock panel, everything displays properly.