SCROLLVIEWER DOES NOT SCROLL IMAGE WPF

jacob rasel

Total Post:88

Points:616
Posted by  jacob rasel
C# 
C#
 1881  View(s)
Ratings:
Rate this:

I have an image that is bigger than it's window container and it is placed in a ScrollViewer, however, the image does not scroll at all. I've tried putting the image in a container with no luck. What settings am I missing here? (I copied the code straight from MS, but they have it wrong)

Here's the code:

<Window

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

xmlns:h="http://helixtoolkit.codeplex.com" x:Class="TileLayout"

Title="TileLayout" Height="1000" Width="845" WindowStartupLocation="CenterScreen" WindowStyle="ThreeDBorderWindow">

<StackPanel HorizontalAlignment="center" VerticalAlignment="Top">

    <StackPanel Orientation="Horizontal"   >

        <TextBox x:Name="txtSourceFilePath" Width="500" Margin="10" Height="22" TextChanged="TextBox_TextChanged" Text="E:\projects\Test3D\SavedSnapshots\snapshot.png"/>

        <Button x:Name="btnPickFile" Width="100" Margin="0,10,10,10" Content="Pick File" ></Button>

    </StackPanel>

    <ScrollViewer VerticalScrollBarVisibility="Auto" >

        <Image x:Name="imgFinal" Source="SteelMotion_chevron2.png"/>

    </ScrollViewer>

</StackPanel>

  1. Pravesh Singh

    Post:412

    Points:2888
    Re: ScrollViewer does not scroll Image WPF

    Hi Jacob,


    <Window

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    xmlns:h="http://helixtoolkit.codeplex.com" x:Class="TileLayout"

    Title="TileLayout" Height="1000" Width="845" WindowStartupLocation="CenterScreen" WindowStyle="ThreeDBorderWindow">

    <Grid>

        <Grid.RowDefinitions>

            <RowDefinition Height="50"/>

            <RowDefinition Height="*"/>

        </Grid.RowDefinitions>

        <StackPanel Orientation="Horizontal" Height="50"  HorizontalAlignment="Center" VerticalAlignment="Top" Grid.Row="0">

            <TextBox x:Name="txtSourceFilePath" Width="500" Margin="10" Height="22" TextChanged="TextBox_TextChanged" Text=""/>

            <Button x:Name="btnPickFile" Width="100" Margin="0,10,10,10" Content="Pick File" ></Button>

        </StackPanel>

        <ScrollViewer VerticalScrollBarVisibility="Auto" Grid.Row="1" >

            <Image x:Name="imgFinal" Source="SteelMotion_chevron2.png" Width="768" Height="1408"/>

        </ScrollViewer>

    </Grid>

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!