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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:48:21+00:00 2026-05-26T04:48:21+00:00

This is not your average My ScrollViewer isn’t working question… Assume a window with

  • 0

This is not your average “My ScrollViewer isn’t working” question…
Assume a window with a grid. The sizes of column 0 and row 1 are set to Auto, column 1 and row 0 are set to *. (important)
In cell [0, 0] there is an ItemsControl with a Template with a StackPanel inside a ScrollViewer inside a Grid. The reason is simple: Show a scroll bar if not all items in the ItemsControl can be displayed. The visibility of the vertical scrollbar is set to Auto (important).
In Cell [1, 1] there is a Button that displays its width.

If the window is too small too display all items in the ItemsControl this will lead to the following:
The scroll bar will be there but it is not visible. It is working, because I can scroll using the mouse wheel. The reason seems to be that the grid column in which the ItemsControl is contained is not automatically extended to make space for the scrollbar.

If I change (nearly) any of the parameters, the scroll bar is displayed as expected and the second column is reduced in size. Can anyone explain this odd behavior?


Additional Info:

The following parameter changes will lead to the scrollbar becoming visible:

  1. Changing size of column 0 to *
  2. Changing size of column 1 to Auto
  3. Changing size of row 1 to *
  4. Removing the Button.
  5. Moving the Button to [0, 1] or [1, 0]
  6. Manually setting the width of the ItemsControl.
  7. Setting the VerticalScrollBarVisibility of the ScrollViewer in the ItemsControl to Visible.

However, changing the button in [1, 1] to something else, e.g. another ItemsControl doesn’t change the strange behavior, so it has nothing to with the button. Furthermore, changing the width of the Button to something that is smaller than the second column, also doesn’t remove that behavior.


Complete sample code for reproduction:

<Window x:Class="WpfApplication4.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="343" Width="253">
  <Grid>
    <Grid.ColumnDefinitions>
      <ColumnDefinition Width="Auto" />
      <ColumnDefinition Width="*" />
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
      <RowDefinition Height="*" />
      <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>
    <ItemsControl>
      <ItemsControl.Template>
        <ControlTemplate>
          <Grid>
            <Grid.RowDefinitions>
              <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <ScrollViewer VerticalScrollBarVisibility="Auto">
              <StackPanel IsItemsHost="True" />
            </ScrollViewer>
          </Grid>
        </ControlTemplate>
      </ItemsControl.Template>
      <ItemsControl.Items>
        <Button Content="Column1" Height="500" />
      </ItemsControl.Items>
    </ItemsControl>
    <Button Content="{Binding ActualWidth, RelativeSource={RelativeSource Self}}"
            Grid.Column="1" Grid.Row="1" />
  </Grid>
</Window>
  • 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-26T04:48:21+00:00Added an answer on May 26, 2026 at 4:48 am

    Looks like it might be a known bug in WPF. This question deals with a ListBox’s ScrollViewer, but I think the principal is the same.

    As an alternative, you could add something behind the ScrollViewer that has it’s width bound to the ScrollViewer’s ActualWidth, which will force the column to draw the correct size

    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
    
        <ScrollViewer x:Name="Test" Grid.Row="0" Grid.Column="0" 
                      VerticalScrollBarVisibility="Auto">
            <Button Content="Column1" Height="500" />
        </ScrollViewer>
    
        <Grid Grid.Column="0" Grid.Row="0" 
              Width="{Binding ElementName=Test, Path=ActualWidth}" />
    
        <Button Content="{Binding ActualWidth, RelativeSource={RelativeSource Self}}"
            Grid.Column="1" Grid.Row="1" />
    </Grid>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So, this is not your average 'conditional sort by' question... I have a rather
This one is a case of not doing your homework.:-) Apart from dynamic loading
Sorry for this not being a real question, but Sometime back i remember seeing
So why is this not working? I'm creating a regex that will match a
This question is not for the faint of heart and will be time consuming..
I ask this not to start anything negative. Rather, after looking at ASP.NET MVC
why is this not ok? aContract = function(){}; aContract.prototype = { someFunction: function() {
Why does this not work? Do I not understand delegate covariance correctly? public delegate
Under what circumstances would this or would this not be safe? I have a
I've done this before with inputs, why on earth does this not work? http://euroworker.no/user/checkout

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.