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 634495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:18:07+00:00 2026-05-13T20:18:07+00:00

I am using a grid by the definition of appropriateness defined in this question

  • 0

I am using a grid by the definition of appropriateness defined in this question Grid vs Stackpanel. However when working with grids you have to define the controls position inside them explicitly in the grid. This becomes a pain when having to reorder controls or when adding a new control to the grid. With the code provided as an example, is there a way to get the rows and columns for the text and text boxes to line up while being easy to modify or expand later?

<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="3*"/>
        <ColumnDefinition Width="7*"/>
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition />
        <RowDefinition />
        <RowDefinition />
    </Grid.RowDefinitions>
    <TextBlock Text="Value One:"   Grid.Row="0" Grid.Column="0"/>
        <TextBox x:Name="TextBoxOne"   Grid.Row="0" Grid.Column="1"/>

    <TextBlock Text="Value Two:"   Grid.Row="1" Grid.Column="0"/>
        <TextBox x:Name="TextBoxTwo"   Grid.Row="1" Grid.Column="1"/>

    <TextBlock Text="Value Three:" Grid.Row="2" Grid.Column="0"/>
        <TextBox x:Name="TextBoxThree" Grid.Row="2" Grid.Column="1"/>
</Grid>
  • 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-13T20:18:07+00:00Added an answer on May 13, 2026 at 8:18 pm

    I wrote a custom control I use that makes it extremely easy to do this, but before I created it I generally used this sort of thing:

    <ControlTemplate x:Key="ColumnsTemplate" TargetType="HeaderedContentControl">
      <Grid>
        <Grid.ColumnDefinitions>
          <ColumnDefinition Width="3*" />
          <ColumnDefinition Width="7*" />
        </Grid.ColumnDefinitions>
        <ContentPresenter Grid.Column="0" ContentSource="Header" />
        <ContentPresenter Grid.Column="1" />
      </Grid>
    </ControlTemplate>
    
    <ItemsControl ... ItemTemplate="{StaticResource ColumnsTemplate}">
      <HeaderedContentControl Header="Value One:">
        <TextBox x:Name="TextBoxOne" />
      </HeaderedContentControl>
      <HeaderedContentControl Header="Value Two:">
        <TextBox x:Name="TextBoxTwo" />
      </HeaderedContentControl>
      ...
    </ItemsControl>
    

    This allows easy add/remove of items from the ItemsControl, or better yet, data binding.

    If you prefer auto-sizing on the grid rather than star sizing (3* and 7*) you can use a shared sizing scope by setting IsSharedSizeScope on the ItemsControl and SharedSizeGroup on the first ColumnDefinition.

    Another option is GridView, but I find it more difficult to use for this purpose.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a grid with the following definition. Everything is working fine with the
I'm not using a Grid, just using the MvcContrib Pager. I have a partial
We're using Infragistics grid (most probably, we'll have 8.2 version at the end) and
I'm able to change the width/height of the grid using this, so why won't
(This is not a question per se, I'm documenting a solution I found using
Is it possible to design something like this using Grid in WPF? Design columns
I am using a GridSplitter to resize a cell in a grid however its
This may be a similar question to Linker errors 2005 and 1169 (multiply defined
I have the following definition for a DatePicker : <sdk:DatePicker x:Name=dtpStartDate Grid.Row=4 Grid.Column=1 SelectedDateFormat=Short
hi I have seen a couple of answers for this question but i have

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.