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

  • Home
  • SEARCH
  • 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 315533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T08:18:01+00:00 2026-05-12T08:18:01+00:00

The scrollviewer below does not work. I tried everything I could find on this

  • 0

The scrollviewer below does not work. I tried everything I could find on this site and beyond: embedding the scrollviewer in an Grid, embedding the ScrollViewer’s children in a grid, embedding the Scrollviewer in a StackPanel with fixed height, setting/binding the height of the scrollviewer, all to no avail… Who shows me the way back to sanity??

Mind, the XAML below is just to show how the window is structured. I removed all the data.

<Window>
    <Window.Resources>
        <DataTemplate x:Key="ColoringLabels">
        </DataTemplate>
    </Window.Resources>
    <DockPanel>
        <StatusBar DockPanel.Dock="Top">
            <StatusBarItem>
            </StatusBarItem>
        </StatusBar>
        <StackPanel Orientation="Vertical">
            <TextBox/>
            <Button>Hello World!</Button>
            <ScrollViewer>
                <StackPanel Orientation="Vertical">
                    <Label>Hola Mundo!</Label>
                    <ListBox ItemsSource="{Binding}">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <ListBox ItemsSource="{StaticResource ColoringLabels}"/>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                    <ListBox Source="{Binding}"ItemTemplate="{StaticResource ColoringLabels}"/>
                </StackPanel>
            </ScrollViewer>
            <TextBlock/>
        </StackPanel>
    </DockPanel>
</Window>

EDIT:

I solved it by changing the XAML to:

<Window>
   <Window.Resources>
       <DataTemplate x:Key="ColoringLabels">
       </DataTemplate>
   </Window.Resources>
   <DockPanel>
       <StatusBar DockPanel.Dock="Top">
           <StatusBarItem>
           </StatusBarItem>
       </StatusBar>
       <ScrollViewer>
            <StackPanel Orientation="Vertical">
                <TextBox />
                <Button>Hello World!</Button>
                    <StackPanel Orientation="Vertical">
                        <Label>Hola Mundo!</Label>
                        <ListBox ItemsSource="{Binding}">
                            <ListBox.ItemTemplate>
                                <DataTemplate>
                                    <ListBox ItemsSource="{StaticResource ColoringLabels}"/>
                                </DataTemplate>
                            </ListBox.ItemTemplate>
                        </ListBox>
                        <ListBox Source="{Binding}"ItemTemplate="{StaticResource ColoringLabels}"/>
                    </StackPanel>
                <TextBlock/>
            </StackPanel>
        </ScrollViewer>
    </DockPanel>
</Window>

Why it is working now??? Perhaps because the ScrollViewer now gets to fill the LastChild position of the DockPanel???

  • 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-12T08:18:01+00:00Added an answer on May 12, 2026 at 8:18 am

    try this

    <Window x:Class="WpfApplication7.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Window1" Height="308" Width="527">
        <Window.Resources>
            <DataTemplate x:Key="ColoringLabels">
            </DataTemplate>
        </Window.Resources>
        <DockPanel LastChildFill="True">
            <StackPanel DockPanel.Dock="Top" HorizontalAlignment="Stretch">
                <StatusBar>
                    <StatusBarItem>
                    </StatusBarItem>
                </StatusBar>
                <TextBox/>
                <Button>Hello World!</Button>
            </StackPanel>
            <ScrollViewer>
                <StackPanel Orientation="Vertical" >
                    <Label>Hola Mundo!</Label>
                    <ListBox ItemsSource="{Binding}">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <ListBox />
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                    <ListBox />
                </StackPanel>
            </ScrollViewer>
            <TextBlock/>
        </DockPanel>
    
    </Window>
    

    EDIT
    Your new code is working just becouse scrollviewer size is fixed now(it’s fill the free part of screen), and it is not growing outside the window when it’s content is growing…

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

Sidebar

Ask A Question

Stats

  • Questions 189k
  • Answers 189k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Sorry if I don't understand you completely, but you just… May 12, 2026 at 5:44 pm
  • Editorial Team
    Editorial Team added an answer Microsoft has an excellent set of guidelines on class library… May 12, 2026 at 5:44 pm
  • Editorial Team
    Editorial Team added an answer If your cursors are global(I guess you used local cursors… May 12, 2026 at 5:44 pm

Related Questions

In my XAML and when I build I get the following exception: Error 3
The following code-behind binding works for the SmartFormView user control: View: <UserControl x:Class=CodeGenerator.Views.PageItemManageSettingsView xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation
I have a textbox that I want to be watermarked. In my window.resources section
I’m making a simple LOB app which loads data from an XML file and

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.