ARTICLE

WPF ScrollViewer with Image control in VB.NET

Posted by Rohatash Kumar Articles | XAML in VB.NET March 07, 2011
Here we will see how to create an application in which a Image work with ScrollViewer in XAML.
Download Files:
 
Reader Level:

Here we will see how to create an application in which a Image work with ScrollViewer in XAML.

For example

Creating  a image control and ScrollViewer control in XAML. The below code defines the Image control and ScrollViewer control.

Creating Image in XAML

<Image Height="150" HorizontalAlignment="Left" Margin="124,21,0,0" Name="Image1" Stretch="Fill" VerticalAlignment="Top" Width="200" />

Using source property

<Image Height="150" HorizontalAlignment="Left" Margin="124,21,0,0" Name="Image1" Stretch="Fill" VerticalAlignment="Top" Width="200" Source="/WpfApplication81;component/Images/image1.jpg.gif" />

Creating ScrollViewer with image

XAML code

<Window x:Class="MainWindow"

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

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

    Title="MainWindow" Height="350" Width="525">

    <ScrollViewer

    x:Name="scrollViewImage"

    HorizontalScrollBarVisibility="Visible"

    VerticalScrollBarVisibility="Visible" >

    <Grid

    x:Name="gridImageContainer"

    Background="Gray"

    ShowGridLines="True">

    <Grid.ColumnDefinitions>

    <ColumnDefinition></ColumnDefinition>

     </Grid.ColumnDefinitions>

     <Grid.RowDefinitions>

         <RowDefinition></RowDefinition>

            </Grid.RowDefinitions>

            <Image

         Grid.Row="0" Grid.Column="0" Name="Image1" Source="/WpfApplication81;component/Images/file5.jpg">

            </Image>

        </Grid>

    </ScrollViewer>

</Window>

Now run the application.

sc.gif

Figure1.gif

Now increase the ScrollViewer.

sc1.gif

Figure2.gif

Login to add your contents and source code to this article
share this article :
post comment
 
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
Team Foundation Server Hosting
Become a Sponsor