Home > DeveloperSection > Forums > ScrollViewer does not scroll Image WPF
jacob rasel
jacob rasel

Total Post:88

Points:616
Posted on    January-30-2014 11:18 PM

 C# C# 
Ratings:


 1 Reply(s)
 1241  View(s)
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>



Pravesh Singh

Total Post:411

Points:2881
Posted on    January-30-2014 11:38 PM

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>


Don't want to miss updates? Please click the below button!

Follow MindStick