Use the methods that are defined by the IScrollInfo interface to scroll the child content of a StackPanel. : StackPanel « Windows Presentation Foundation « VB.Net

Home
VB.Net
1.2D
2.Application
3.Class
4.Data Structure
5.Data Types
6.Database ADO.net
7.Development
8.Event
9.File Directory
10.Generics
11.GUI
12.Language Basics
13.LINQ
14.Network Remote
15.Security
16.Thread
17.Windows Presentation Foundation
18.Windows System
19.XML
20.XML LINQ
VB.Net Tutorial
VB.Net by API
VB.Net » 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.vb
Imports System
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Controls.Primitives
Imports System.Windows.Documents
Imports System.Windows.Navigation
Imports System.Text

Namespace ScrollViewer_Methods
  Public Partial Class Window1
    Inherits Window
    Private Sub onLoad(sender As Object, e As System.EventArgs)
      DirectCast(sp1, IScrollInfo).CanVerticallyScroll = True
      DirectCast(sp1, IScrollInfo).CanHorizontallyScroll = True
      DirectCast(sp1, IScrollInfo).ScrollOwner = sv1
    End Sub
    Private Sub spLineUp(sender As Object, e As RoutedEventArgs)
      DirectCast(sp1, IScrollInfo).LineUp()
    End Sub
    Private Sub spLineDown(sender As Object, e As RoutedEventArgs)
      DirectCast(sp1, IScrollInfo).LineDown()
    End Sub
    Private Sub spLineRight(sender As Object, e As RoutedEventArgs)
      DirectCast(sp1, IScrollInfo).LineRight()
    End Sub
    Private Sub spLineLeft(sender As Object, e As RoutedEventArgs)
      DirectCast(sp1, IScrollInfo).LineLeft()
    End Sub
    Private Sub spPageUp(sender As Object, e As RoutedEventArgs)
      DirectCast(sp1, IScrollInfo).PageUp()
    End Sub
    Private Sub spPageDown(sender As Object, e As RoutedEventArgs)
      DirectCast(sp1, IScrollInfo).PageDown()
    End Sub
    Private Sub spPageRight(sender As Object, e As RoutedEventArgs)
      DirectCast(sp1, IScrollInfo).PageRight()
    End Sub
    Private Sub spPageLeft(sender As Object, e As RoutedEventArgs)
      DirectCast(sp1, IScrollInfo).PageLeft()
    End Sub
  End Class
End Namespace

   
    
    
    
    
  
Related examples in the same category
1.StackPanel with Button, Ellipse and ListBoxStackPanel with Button, Ellipse and ListBox
2.Set DataContext for StackPanelSet DataContext for StackPanel
3.Arrange UI Elements in a Horizontal or Vertical StackArrange UI Elements in a Horizontal or Vertical Stack
4.StackPanel with Image BackGroundStackPanel with Image BackGround
5.Vertical StackPanelVertical StackPanel
6.Horizontal StackPanelHorizontal StackPanel
7.Put buttons to StackPanelPut buttons to StackPanel
8.Focus scope for StackPanelFocus scope for StackPanel
9.Add Button and TextBox to StackPanelAdd Button and TextBox to StackPanel
10.Align left along StackPanelAlign left along StackPanel
11.StackPanel with MinHeight, MinWidth, VerticalAlignment, HorizontalAlignmentStackPanel with MinHeight, MinWidth, VerticalAlignment, HorizontalAlignment
12.StackPanel with Label and TextBoxStackPanel with Label and TextBox
13.StackPanel search layoutStackPanel search layout
14.Using StackPanel to group elements for absolute positioningUsing StackPanel to group elements for absolute positioning
15.Search for an element by using Panel.FindName()Search for an element by using Panel.FindName()
16.Change StackPanel OrientationChange StackPanel Orientation
17.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.