Search This Blog

Wednesday, October 30, 2013

WPF ScrollViewer

WPF > Controls  > ContentControl > ScrollViewer

WPF ScrollViewer control enables scrolling of content.
Sometimes the content is larger than a computer screen display area. This control encapsulates ScrollBar elements and a content container.

WPF ScrollViewer Example:

XAML:

<Window x:Class="ScrollViewer.MainWindow"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  Title="MainWindow" Height="406" Width="411">
    <ScrollViewer HorizontalScrollBarVisibility="Auto"   VerticalScrollBarVisibility="Auto">
       <StackPanel VerticalAlignment="Top" HorizontalAlignment="Left">
           <TextBlock TextWrapping="Wrap">ScrollViewer Example. Resize the window to see functionality</TextBlock>
           <Rectangle Fill="Blue" Width="400" Height="400"></Rectangle>
       </StackPanel>
   </ScrollViewer>
</Window>