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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:56:43+00:00 2026-06-17T20:56:43+00:00

In the WPF grid below, the middle column is not 6. Text B is

  • 0

In the WPF grid below, the middle column is not 6. Text B is all the way to the right instead of 6 away from Text A. I have tried * instead of Auto for the other columns but the result is the same.

How do I make the middle column 6? Is there a workaround? Why is it happening? Is it intended behaviour or a bug?

I make my grids this way so that I don’t have to set a margin on every element.

<ScrollViewer HorizontalScrollBarVisibility="Auto">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="6" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>

        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="6" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <TextBlock Grid.ColumnSpan="3" Grid.Column="0" HorizontalAlignment="Left">xxxxxxxxxxxxxxxxxxxxxxxxxxxx</TextBlock>
        <TextBlock Grid.Row="2">Text A</TextBlock>
        <Rectangle Fill="YellowGreen" Grid.Column="1" Grid.Row="2" HorizontalAlignment="Stretch" />
        <TextBlock Grid.Row="2" Grid.Column="2"  Background="LightCoral">Text B</TextBlock>
    </Grid>
</ScrollViewer>

Note: My window width is Auto.

Edit:
Using @flq’s solution but added a scrollviewer with horizontal scrolling, the problem is back. It’s probably the same reason as why the solution doesn’t show properly in the designer, something to do with WPF not knowing how to calculate widths without a constraining width.

  • 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-06-17T20:56:45+00:00Added an answer on June 17, 2026 at 8:56 pm

    How do I make the middle column 6? Is there a workaround?

    Solved by setting a MaxWidth inside the ScrollViewer (I used the largest double value).

    Why is it happening? Is it intended behaviour or a bug?

    In a ScrollViewer (or the designer), there is no maximum width. Somewhere in the layout calculations it is assigning the column width as 6 + *.

    I think ultimately it is a bug because the column width can be calculated without needing a max width (it is specified as a fixed value and does not even need to be calculated).

    <ScrollViewer HorizontalScrollBarVisibility="Auto">
        <Grid MaxWidth="1.79769E308">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="6" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
    
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="6" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
    
            <TextBlock Grid.ColumnSpan="4">xxxxxxxxxxxxxxxxxxxxxxxxxxxx</TextBlock>
            <TextBlock Grid.Row="2">Text A</TextBlock>
            <Rectangle Fill="YellowGreen" Grid.Column="1" Grid.Row="2" />
            <TextBlock Grid.Row="2" Grid.Column="2" Background="LightCoral">Text B</TextBlock>
        </Grid>
    </ScrollViewer>
    

    This is the result

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

Sidebar

Related Questions

The code below is in WPF in .net 4, which shows a grid which
Say I have a very simple WPF grid (6 rows x 6 columns) defined
I need to create a WPF grid dynamically from code behind. This is going
I have been hiding a row in a WPF grid by setting the Height
I have a WPF ListView , where I bind an observable collection, and below
I have a datagrid like below in my WPF application. <Window x:Class=MyApp.TestWindow xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml>
I have a treeview in wpf that is built using the xaml below. It
I have the following XAML below for the main window in my WPF application,
I have a WPF Data Grid bound to an observable collection, which is working
I have the following xaml which resides in a wpf user control - <Grid>

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.