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

Home
C# / CSharp Tutorial
1.Language Basics
2.Data Type
3.Operator
4.Statement
5.String
6.struct
7.Class
8.Operator Overload
9.delegate
10.Attribute
11.Data Structure
12.Assembly
13.Date Time
14.Development
15.File Directory Stream
16.Preprocessing Directives
17.Regular Expression
18.Generic
19.Reflection
20.Thread
21.I18N Internationalization
22.LINQ
23.GUI Windows Forms
24.Windows Presentation Foundation
25.Windows Communication Foundation
26.Workflow
27.2D
28.Design Patterns
29.Windows
30.XML
31.XML LINQ
32.ADO.Net
33.Network
34.Directory Services
35.Security
36.unsafe
C# / C Sharp
C# / C Sharp by API
C# / CSharp Open Source
C# / CSharp Tutorial » Windows Presentation Foundation » ScrollViewer 
24.53.5.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();
        }

    }
}
WPF Use The Contentscrolling Methods Of The Scroll Viewer Class
24.53.ScrollViewer
24.53.1.Put Canvas into ScrollViewerPut Canvas into ScrollViewer
24.53.2.Default Thumb StyleDefault Thumb Style
24.53.3.StackPanel in a ScrollViewerStackPanel in a ScrollViewer
24.53.4.ScrollViewer and Big EllipseScrollViewer and Big Ellipse
24.53.5.Use the content-scrolling methods of the ScrollViewer classUse the content-scrolling methods of the ScrollViewer class
24.53.6.Scroll Buttons with ScrollViewer
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.