Use Slider to control TranslateTransform


   
    

<StackPanel xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Label Content="X" />
    <ScrollBar Name="xscroll" Orientation="Horizontal" Minimum="-300" Maximum="1000" />
    <TextBlock HorizontalAlignment="Center" Text="{Binding ElementName=xscroll, Path=Value}" />

    <Label Content="Y" />
    <ScrollBar Name="yscroll" Orientation="Horizontal" Minimum="-300" Maximum="1000" />
    <TextBlock HorizontalAlignment="Center" Text="{Binding ElementName=yscroll, Path=Value}" />

    <Canvas>
        <Button Content="Button" Canvas.Left="100" Canvas.Top="100">
            <Button.RenderTransform>
                <TranslateTransform 
                    X="{Binding ElementName=xscroll, Path=Value}"
                    Y="{Binding ElementName=yscroll, Path=Value}" />
            </Button.RenderTransform>
        </Button>
    </Canvas>
</StackPanel>

   
    
    
    
     


Use Slider to control SkewTransform


   
    
<StackPanel xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <Label Content="AngleX" />
    <ScrollBar Name="xscroll" Orientation="Horizontal" Value="0" Minimum="-90" Maximum="90" />
    <TextBlock HorizontalAlignment="Center" Text="{Binding ElementName=xscroll, Path=Value}" />

    <Label Content="AngleY" />
    <ScrollBar Name="yscroll" Orientation="Horizontal" Value="0" Minimum="-90" Maximum="90" />
    <TextBlock HorizontalAlignment="Center" Text="{Binding ElementName=yscroll, Path=Value}" />

    <Label Content="CenterX" />
    <ScrollBar Name="xcenter" Orientation="Horizontal" Value="0" Minimum="-100" Maximum="100" /> 
    <TextBlock HorizontalAlignment="Center" Text="{Binding ElementName=xcenter, Path=Value}" />

    <Label Content="CenterY" />
    <ScrollBar Name="ycenter" Orientation="Horizontal" Value="0" Minimum="-100" Maximum="100" />
    <TextBlock HorizontalAlignment="Center" Margin="12" Text="{Binding ElementName=ycenter, Path=Value}" />

    <Canvas>
        <Button Name="btn" Content="Button" Canvas.Left="100" Canvas.Top="100">
            <Button.RenderTransform>
                <SkewTransform
                    AngleX="{Binding ElementName=xscroll, Path=Value}"
                    AngleY="{Binding ElementName=yscroll, Path=Value}" 
                    CenterX="{Binding ElementName=xcenter, Path=Value}"
                    CenterY="{Binding ElementName=ycenter, Path=Value}" />
            </Button.RenderTransform>
        </Button>

        <StackPanel>
            <TextBlock Text="{Binding ElementName=btn, Path=ActualWidth}" />
            <TextBlock Text="::" />
            <TextBlock Text="{Binding ElementName=btn, Path=ActualHeight}" />
        </StackPanel>
    </Canvas>
</StackPanel>

   
    
    
    
     


Use Slider to control the ScaleTransform


   
    

<StackPanel xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <Label Content="ScaleX" />
    <ScrollBar Name="xscroll" Orientation="Horizontal" Value="1" Minimum="-20" Maximum="20" />
    <TextBlock HorizontalAlignment="Center" Text="{Binding ElementName=xscroll, Path=Value}" />

    <Label Content="ScaleY" />
    <ScrollBar Name="yscroll" Orientation="Horizontal" Value="1" Minimum="-20" Maximum="20" />
    <TextBlock HorizontalAlignment="Center" Text="{Binding ElementName=yscroll, Path=Value}" />

    <Label Content="CenterX" />
    <ScrollBar Name="xcenter" Orientation="Horizontal" Value="0" Minimum="-100" Maximum="100" /> 
    <TextBlock HorizontalAlignment="Center" Margin="12" Text="{Binding ElementName=xcenter, Path=Value}" />

    <Label Content="CenterY" />
    <ScrollBar Name="ycenter" Orientation="Horizontal" Value="0" Minimum="-100" Maximum="100" />
    <TextBlock HorizontalAlignment="Center" Margin="12" Text="{Binding ElementName=ycenter, Path=Value}" />

    <Canvas>
        <Button Name="btn" Content="Button" Canvas.Left="100" Canvas.Top="100">
            <Button.RenderTransform>
                <ScaleTransform
                    ScaleX="{Binding ElementName=xscroll, Path=Value}"
                    ScaleY="{Binding ElementName=yscroll, Path=Value}" 
                    CenterX="{Binding ElementName=xcenter, Path=Value}"
                    CenterY="{Binding ElementName=ycenter, Path=Value}" />
            </Button.RenderTransform>
        </Button>

        <StackPanel>
            <TextBlock Text="{Binding ElementName=btn, Path=ActualWidth}" />
            <TextBlock Text="::" />
            <TextBlock Text="{Binding ElementName=btn, Path=ActualHeight}" />
        </StackPanel>
    </Canvas>
</StackPanel>

   
    
    
    
     


Add Separator to StackPanel


   
    

<Window x:Class="Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="193" Width="197">
    <Grid>
        <StackPanel Name="StackPanel1">
            <Button Height="23" Name="Button1">Button</Button>
            <Button Height="23" Name="Button2" Width="Auto">Button</Button>
            <Separator Height="5" Name="Separator1" Width="Auto" />
            <Button Height="23" Name="Button3" >Button</Button>
        </StackPanel>
    </Grid>
</Window>

   
    
    
    
     


Use the content-scrolling methods of the ScrollViewer class



ScrollViewer Content Scrolling Methods

















//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(); } } } [/csharp]

StackPanel in a ScrollViewer


   
      
<Window x:Class="WpfApplication1.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="ScrollViewerWithExpander" Height="300" Width="300">
    <ScrollViewer VerticalScrollBarVisibility="Auto">
        <StackPanel Orientation="Vertical">
            <Button Width="200" >A</Button>
            <Expander Header="Expand me" BorderThickness="3" BorderBrush="Black">
                <StackPanel>
                    <Button>B</Button>
                    <Button>C</Button>
                    <Button>D</Button>
                </StackPanel>
            </Expander>
            <Button Padding="10 4" HorizontalAlignment="Right">E</Button>
            <Button HorizontalAlignment="Stretch">F</Button>
        </StackPanel>
    </ScrollViewer>
</Window>