-1

Why do the scrollbars not appear with the following XAML?

<Window x:Class="GridViewsToImagePocApp.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlna:telerik="http://schemas.telerik.com/2008/xaml/presentation"
        Title="MainWindow" Height="600" Width=800">
    <StackPanel>
        <ScrollViewer IsEnabled="True" HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Visible">
            <StackPanel>
                <telerik:RadGridView x:Name="GridView1" AutoGenerateColumns="True" />
                <telerik:RadGridView x:Name="GridView2" AutoGenerateColumns="True" Margin="0 15 0 0" />
                <telerik:RadGridView x:Name="GridView3" AutoGenerateColumns="True" Margin="0 15 0 0" />
                <telerik:RadGridView x:Name="GridView4" AutoGenerateColumns="True" Margin="0 15 0 0" />
                <telerik:RadGridView x:Name="GridView5" AutoGenerateColumns="True" Margin="0 15 0 0" />
            </StackPanel>
        </ScrollViewer>
    </StackPanel>
</Window>
1
  • 2
    Please try to post your code instead of a screenshot. Commented Oct 7, 2021 at 13:25

1 Answer 1

1

The outer StackPanel is the issue. It measures its children with positive infinity (height in Vertical Orientation or width in Horizontal orientation). Hence the ScrollViewer is not restricted in any way, so it expands to fit its content and does not need to display any scrollbars.

Use a panel that restricts the size of the ScrollViewer to the available space instead, like Grid, UniformGrid or DockPanel, depending on your requirements.

<Grid>
   <ScrollViewer CanContentScroll="True" HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Visible">
      <StackPanel>
         <!-- ...your content. -->
      </StackPanel>
   </ScrollViewer>
</Grid>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.