Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 819467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T02:18:53+00:00 2026-05-15T02:18:53+00:00

I’m very new to WPF and XAML. I am trying to design a basic

  • 0

I’m very new to WPF and XAML. I am trying to design a basic data entry form. I have used a stack panel holding four more stack panels to get the layout I want. Perhaps a grid would be better for this, I am not sure.

And here is the XAML code that generates it:

<Window x:Class="Test1.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="224" Width="536.762">
    <StackPanel Height="Auto" Name="stackPanel1" Width="Auto" Orientation="Horizontal">
        <StackPanel Height="Auto" Name="stackPanel2" Width="Auto">
            <Label Height="Auto" Name="label1" Width="Auto">Patient Name:</Label>
            <Label Height="Auto" Name="label2" Width="Auto">Physician:</Label>
            <Label Height="Auto" Name="label3" Width="Auto">Insurance:</Label>
            <Label Height="Auto" Name="label4" Width="Auto">Therapy Goals:</Label>
        </StackPanel>
        <StackPanel Height="Auto" Name="stackPanel3" Width="Auto">
            <TextBox Height="Auto" Name="textBox1" Width="Auto" Padding="3" Margin="1" />
            <TextBox Height="Auto" Name="textBox2" Width="Auto" Padding="3" Margin="1" />
            <TextBox Height="Auto" Name="textBox3" Width="Auto" Padding="3" Margin="1" />
            <TextBox Height="Auto" Name="textBox4" Width="Auto" Padding="3" Margin="1" />
        </StackPanel>
        <StackPanel Height="Auto" Name="stackPanel4" Width="Auto">
            <Label Height="Auto" Name="label5" Width="Auto">Date:</Label>
            <Label Height="Auto" Name="label6" Width="Auto">Patient Phone:</Label>
            <Label Height="Auto" Name="label7" Width="Auto">Facility:</Label>
            <Label Height="Auto" Name="label8" Width="Auto">Referring Physician:</Label>
        </StackPanel>
        <StackPanel Height="Auto" Name="stackPanel5" Width="Auto">
            <TextBox Height="Auto" Name="textBox5" Width="Auto" Padding="3" Margin="1" />
            <TextBox Height="Auto" Name="textBox6" Width="Auto" Padding="3" Margin="1" />
            <TextBox Height="Auto" Name="textBox7" Width="Auto" Padding="3" Margin="1" />
            <TextBox Height="Auto" Name="textBox8" Width="Auto" Padding="3" Margin="1" />
        </StackPanel>
    </StackPanel>
</Window>

What I really want is for the text boxes to stretch equally to fill up the space horizontally. I would also like for the controls in each vertical stackpanel to ‘spread out’ evenly as the window is resized vertically.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T02:18:53+00:00Added an answer on May 15, 2026 at 2:18 am

    StackPanel always aligns its children against the top or left edge depending upon its orientation. It sounds like what you want is a UniformGrid where your outer StackPanel is. Try this:

    <Window>
        <UniformGrid Name="stackPanel1" Rows="1">
            <StackPanel Name="stackPanel2">
               ...
            </StackPanel>
            <StackPanel Name="stackPanel3">
               ...
            </StackPanel>
            <StackPanel Name="stackPanel4">
               ...
            </StackPanel>
            <StackPanel Name="stackPanel5">
               ...
            </StackPanel>
        </UniformGrid>
    </Window>
    

    Note that you don’t need to set Width=Auto or Height=Auto, this is implied.

    But you are right that a Grid is probably better (even though the XAML is ugly) because in this layout configuration your labels could easily get out of alignment with the text boxes. You can try something like this too…

    <UniformGrid Rows="1">
    
        <Grid>
    
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
    
            <Label Grid.Row="0" Grid.Column="0" Content="Field 1" />
            <TextBox Grid.Row="0" Grid.Column="1" />
    
    
            <Label Grid.Row="1" Grid.Column="0" Content="Field 2" />
            <TextBox Grid.Row="1" Grid.Column="1" />
    
    
            <Label Grid.Row="2" Grid.Column="0" Content="Field 3" />
            <TextBox Grid.Row="2" Grid.Column="1" />
    
        </Grid>
    
        <Grid /> <!-- repeat above -->
    
        <Grid /> <!-- etc... -->
    
    </UniformGrid>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a text area in my form which accepts all possible characters from
I am trying to loop through a bunch of documents I have to put
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
Basically, what I'm trying to create is a page of div tags, each has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.