Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enabling Scrollbar in WPF

I'm having a problem right now where my WPF application hides anything below the fold when the window is too small vertically. How can I use XAML to get a vertical scrollbar to appear for the entire app so the user can scroll to see the rest of the content?

like image 549
resopollution Avatar asked Apr 09 '09 22:04

resopollution


People also ask

How do I add a ScrollBar in WPF?

There are two predefined elements that enable scrolling in WPF applications: ScrollBar and ScrollViewer. The ScrollViewer control encapsulates horizontal and vertical ScrollBar elements and a content container (such as a Panel element) in order to display other visible elements in a scrollable area.

How do I add a vertical scroll bar in WPF?

VerticalAlignment="Stretch" ), but on the small screen, automatically display the vertical scroll bar when needed.

How do I add a ScrollBar to XAML?

The <ScrollBar> element of XAML represents a scroll bar control in UI. The ScrollBar control is used to add horizontal and vertical scroll bars to content controls. This tutorial and code examples show how to use a ScrollBar control in a WPF app using XAML. The following code example creates a ScrollBar.

What is a StackPanel WPF?

A StackPanel allows you to stack elements in a specified direction. By using properties that are defined on StackPanel, content can flow both vertically, which is the default setting, or horizontally.


1 Answers

Put a ScrollViewer inside your Window:

<Window x:Class="WpfApplication2.Window1"     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"     Title="Window1" Height="300" Width="300">      <ScrollViewer >         <!-- Window content here -->     </ScrollViewer> </Window> 
like image 172
Jakob Christensen Avatar answered Oct 06 '22 08:10

Jakob Christensen