Use the content-scrolling methods of the ScrollViewer class : ScrollViewer « Windows Presentation Foundation « C# / C Sharp

Home
C# / C Sharp
1.2D Graphics
2.Class Interface
3.Collections Data Structure
4.Components
5.Data Types
6.Database ADO.net
7.Design Patterns
8.Development Class
9.Event
10.File Stream
11.Generics
12.GUI Windows Form
13.Language Basics
14.LINQ
15.Network
16.Office
17.Reflection
18.Regular Expressions
19.Security
20.Services Event
21.Thread
22.Web Services
23.Windows
24.Windows Presentation Foundation
25.XML
26.XML LINQ
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source
C# / C Sharp » Windows Presentation Foundation » ScrollViewerScreenshots 
Use the content-scrolling methods of the ScrollViewer class
Use the content-scrolling methods of the ScrollViewer class
  


<Window  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="ScrollViewer_Methods.Window1"
    Title="ScrollViewer Methods Sample"
    Loaded="onLoad">
  <DockPanel Background="Azure">
    <TextBlock DockPanel.Dock="Top" FontSize="20" FontWeight="Bold" Margin="10">ScrollViewer Content Scrolling Methods</TextBlock>
    <StackPanel DockPanel.Dock="Left" Width="150">
      <Button Margin="3,0,0,2" Background="White" Click="svLineUp">Adjust Line Up</Button>
      <Button Margin="3,0,0,2" Background="White" Click="svLineDown">Adjust Line Down</Button>
      <Button Margin="3,0,0,2" Background="White" Click="svLineRight">Adjust Line Right</Button>
      <Button Margin="3,0,0,2" Background="White" Click="svLineLeft">Adjust Line Left</Button>
      <Button Margin="3,0,0,2" Background="White" Click="svPageUp">Adjust Page Up</Button>
      <Button Margin="3,0,0,2" Background="White" Click="svPageDown">Adjust Page Down</Button>
      <Button Margin="3,0,0,2" Background="White" Click="svPageRight">Adjust Page Right</Button>
      <Button Margin="3,0,0,2" Background="White" Click="svPageLeft">Adjust Page Left</Button>
      <TextBlock Name="txt2" TextWrapping="Wrap"/>
    </StackPanel>
    
    <Border BorderBrush="Black" Height="520" Width="520" VerticalAlignment="Top">
      <ScrollViewer VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Auto" Name="sv1">
        <TextBlock TextWrapping="Wrap" Width="800" Height="1000" Name="txt1"/> 
      </ScrollViewer>
    </Border>
  </DockPanel>
</Window>
//File:Window.xaml.cs

using System;
using System.Windows;
using System.Windows.Automation.Provider;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Navigation;
using System.Text;

namespace ScrollViewer_Methods
{
    public partial class Window1 : Window
    {
        private void onLoad(object sender, System.EventArgs e)
        {
            StringBuilder myStringBuilder = new StringBuilder(400);
            for (int i = 0; i < 100; i++)
            {
                myStringBuilder.Append("this is a test ");
            }
            txt1.Text = myStringBuilder.ToString();
        }
        private void svLineUp(object sender, RoutedEventArgs e)
        {
            sv1.LineUp();
        }
        private void svLineDown(object sender, RoutedEventArgs e)
        {
            sv1.LineDown();
        }
        private void svLineRight(object sender, RoutedEventArgs e)
        {
            sv1.LineRight();
        }
        private void svLineLeft(object sender, RoutedEventArgs e)
        {
            sv1.LineLeft();
        }
        private void svPageUp(object sender, RoutedEventArgs e)
        {
            sv1.PageUp();
        }
        private void svPageDown(object sender, RoutedEventArgs e)
        {
            sv1.PageDown();
        }
        private void svPageRight(object sender, RoutedEventArgs e)
        {
            sv1.PageRight();
        }
        private void svPageLeft(object sender, RoutedEventArgs e)
        {
            sv1.PageLeft();
        }

    }
}

   
    
  
Related examples in the same category
1.Put Canvas into ScrollViewer
2.Default Thumb StyleDefault Thumb Style
3.StackPanel in a ScrollViewerStackPanel in a ScrollViewer
4.ScrollViewer and Big EllipseScrollViewer and Big Ellipse
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.