Use the methods that are defined by the IScrollInfo interface to scroll the child content of a StackPanel. : StackPanel « 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 » StackPanelScreenshots 
Use the methods that are defined by the IScrollInfo interface to scroll the child content of a StackPanel.
Use the methods that are defined by the IScrollInfo interface to scroll the child content of a StackPanel.
  


<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 IScrollInfo Sample"
    Loaded="onLoad">
<DockPanel>
<TextBlock DockPanel.Dock="Top" FontSize="20" FontWeight="Bold" Margin="10">IScrollInfo Interface Methods</TextBlock>
<StackPanel DockPanel.Dock="Left" Width="150">
    <Button Click="spLineUp">Adjust Line Up</Button>
    <Button Click="spLineDown">Adjust Line Down</Button>
    <Button Click="spLineRight">Adjust Line Right</Button>
    <Button Click="spLineLeft">Adjust Line Left</Button>
    <Button Click="spPageUp">Adjust Page Up</Button>
    <Button Click="spPageDown">Adjust Page Down</Button>
    <Button Click="spPageRight">Adjust Page Right</Button>
    <Button Click="spPageLeft">Adjust Page Left</Button>
</StackPanel>  
<Border BorderBrush="Black" Background="White" BorderThickness="2" Width="500" Height="500">
    <ScrollViewer Name="sv1" CanContentScroll="True" VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Visible">
        <StackPanel Name="sp1">
            <Rectangle Width="700" Height="500" Fill="Green"/>
            <TextBlock>Rectangle 3</TextBlock>
        </StackPanel> 
    </ScrollViewer>
</Border>
</DockPanel>
</Window>

//File:Window.xaml.cs
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
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)
        {
            ((IScrollInfo)sp1).CanVerticallyScroll = true;
            ((IScrollInfo)sp1).CanHorizontallyScroll = true;
            ((IScrollInfo)sp1).ScrollOwner = sv1;
        }
        private void spLineUp(object sender, RoutedEventArgs e)
        {
            ((IScrollInfo)sp1).LineUp();
        }
        private void spLineDown(object sender, RoutedEventArgs e)
        {
            ((IScrollInfo)sp1).LineDown();
        }
        private void spLineRight(object sender, RoutedEventArgs e)
        {
            ((IScrollInfo)sp1).LineRight();
        }
        private void spLineLeft(object sender, RoutedEventArgs e)
        {
            ((IScrollInfo)sp1).LineLeft();
        }
        private void spPageUp(object sender, RoutedEventArgs e)
        {
            ((IScrollInfo)sp1).PageUp();
        }
        private void spPageDown(object sender, RoutedEventArgs e)
        {
            ((IScrollInfo)sp1).PageDown();
        }
        private void spPageRight(object sender, RoutedEventArgs e)
        {
            ((IScrollInfo)sp1).PageRight();
        }
        private void spPageLeft(object sender, RoutedEventArgs e)
        {
            ((IScrollInfo)sp1).PageLeft();
        }
    }
}

   
    
  
Related examples in the same category
1.Stretch = Uniform
2.Stretch = UniformToFill
3.Stretch = FillStretch = Fill
4.Stretch = NoneStretch = None
5.StackPanel with StackPanelStackPanel with StackPanel
6.Simple StackPanelSimple StackPanel
7.Set height, Background and Orientation for StackPanelSet height, Background and Orientation for StackPanel
8.Change StackPanel OrientationChange StackPanel Orientation
9.Use StackPanel to arrange child objects in a single line that you can align horizontally or vertically.Use StackPanel to arrange child objects in a single line that you can align horizontally or vertically.
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.