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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:02:38+00:00 2026-05-25T06:02:38+00:00

What I want: I would like to have a ScrollView in my Silverlight 4

  • 0

What I want:
I would like to have a ScrollView in my Silverlight 4 application which grows in Height together with the content, but does show a scrollbar if it would otherwise grow heigher than its container.

Solutions I found:
I found plenty of asked questions where the solution was to strech the Scrollviewer but that is not what I want. The Scrollviewer should always be as small as possible.

My Problem:
To make it a bit more difficult on top of the scrollviewer a header is located which is a stackpanel with static height.

Solution Approch 1:
I tried it firstly with plain XAML but I cant figure out how it should work.

<Grid Height="Auto" x:Name="myGrid" >
    <Grid.RowDefinitions>
        <RowDefinition Height="100"/>
        <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>

    <StackPanel Grid.Row="0" Background="AliceBlue">
        <!-- Dummy Header-->
    </StackPanel>

    <ScrollViewer Grid.Row="1" Height="Auto">
        <Button Width="100"  Height="50" Click="Button_Click" />
        <!-- onClick the button will switch between height="600" and height="50" 
            Code:
            private void Button_Click(object sender, RoutedEventArgs e)
            {
                if (sender is Button)
                {
                    Button btn = (Button)sender;
                    btn.Height = (btn.Height == 50) ? 600 : 50 ;
                }
            }
        -->
    </ScrollViewer>
</Grid>

If You click on the button the it becomes higher and the Scrollviewer will be cut becaus it is to tall. Any sugestions?

Solution Approach 2:
Then I tried to set the *max*Height of the ScrollViewer with the actualHeight of the containing container, therefore I inseted a StackPanel around the ScrollViewer. This does work in the VS2010 XAML designer but not on code execution. I have no clue why…

<Grid Height="Auto" x:Name="myGrid" >
    <Grid.RowDefinitions>
        <RowDefinition Height="100"/>
        <RowDefinition Height="*" />
    </Grid.RowDefinitions>

    <StackPanel Grid.Row="0" Background="AliceBlue">
        <!-- Dummy Header-->
    </StackPanel>
    <StackPanel Grid.Row="1" x:Name="myStackPanel" Height="Auto" VerticalAlignment="Stretch">
        <ScrollViewer Height="Auto" MaxHeight="{Binding ElementName=myStackPanel, Path=ActualHeight}">
            <Button Width="100"  Height="50" Click="Button_Click" />
            <!-- onClick the button will switch between height="600" and height="50" 
                Code:
                private void Button_Click(object sender, RoutedEventArgs e)
                {
                    if (sender is Button)
                    {
                        Button btn = (Button)sender;
                        btn.Height = (btn.Height == 50) ? 600 : 50 ;
                    }
                }
            -->
        </ScrollViewer>
    </StackPanel>
</Grid>

Thanks in advance!

  • 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-25T06:02:38+00:00Added an answer on May 25, 2026 at 6:02 am

    The solution is in the appropriate use of VerticalAlignment. You want the Grid row that contains the scrollview to be the size of the remaining space. You don’t want the Scrollviewer to occupy all that space initially but it needs to be limited to that space. The default VerticalAlignment of Stretch would have occupy all the available size. Using Top instead will cause it to only be as high as it needs to be until the Grid limits it size to the available space.

    <Grid x:Name="myGrid" >
        <Grid.RowDefinitions>
            <RowDefinition Height="100"/>
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <StackPanel Grid.Row="0" Background="AliceBlue">
            <!-- Dummy Header-->
        </StackPanel>
        <ScrollViewer Grid.Row="1" VerticalAlignment="Top" VerticalScrollBarVisibility="Auto">
        </ScrollViewer>
    </Grid>
    

    However note the VerticalScrollBarVisibility which you don’t include in your own xaml despite indications in your text that it should. Perhaps in fact this is what you are really after all along. With that in place remove the VerticalAlignment. Depending on the rest of your scenario you might find that actually have the outline border of the full extent of the scrollviewer makes more sense.

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

Sidebar

Related Questions

I have some MET data I want to validate which would look something like
I have a scrollview with both horizontal and vertical scrolling but I would like
I would like to have a client-server application written in .NET which would do
I have a C++ class I want to inspect. So, I would like to
I would like to upload files just like google mail does. I would want
I would like to achieve the following: I want a free Application Lifecycle Management
I want something like the following but would like it to be reusable for
I have a scrollview with an image as a subview. I would like to
I would like to specify that I want FEATURE_INDETERMINATE_PROGRESS for my Activity . It
I would like to deepen my understanding of data types and want to know

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.