Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. Need help with this control alignment issue

Need help with this control alignment issue

Scheduled Pinned Locked Moved WPF
helpwpfcsharphtmlcom
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Michael Eber
    wrote on last edited by
    #1

    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

    M 1 Reply Last reply
    0
    • M Michael Eber

      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

      M Offline
      M Offline
      Michael Eber
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups