Welcome to MSDN Blogs Sign in | Join | Help
Fun with Ink & Xaml - Part2: Zoom and Scroll

Here is some more fun with ink and Xaml: Scrolling and zooming ink content - in WPF it is as easy as 1,2,3:

1) place an InkCanvas inside a ScrollViewer

2) assign a ScaleTransform to InkCanvas' LayoutTransform

3) data-bind to ScaleX/ScaleY properties in order to zoom in and out

All of this can be done in XAML - no code-behind required. Compare the below simple piece of markup with the code amount and complexity of the Winforms Ink Zoom & Scroll sample from the TabletPC SDK.

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

  <DockPanel>

    <Slider Name="zoomSlider" DockPanel.Dock="Top"

            Minimum="0.1" Maximum="5" Value="1"/>

    <ScrollViewer HorizontalScrollBarVisibility="Auto">

      <InkCanvas Background="Yellow">

        <InkCanvas.LayoutTransform>

          <ScaleTransform ScaleX="{Binding ElementName=zoomSlider,

                                           Path=Value}"

                          ScaleY="{Binding ElementName=zoomSlider,

                                           Path=Value}"/>

        </InkCanvas.LayoutTransform>

      </InkCanvas>

    </ScrollViewer>

  </DockPanel>

</Page>

 

 

The XAML file for this sample is attached to this post. You can load it directly into IE or play with it in XamlPad (see screenshot below). Use the slider on top of the Ink control to adjust the zoom level.

Zoom and scroll ink in XamlPad

Next post in this series: Fun with Ink & XAML Part3: Ink Data Binding

Previous post in this series: Fun with Ink & Xaml - Part1: Ink Reflections

Posted: Friday, November 02, 2007 12:01 AM by swick
Attachment(s): ScrollZoomInk.xaml

Comments

Stefan Wick's Weblog said:

Data binding in WPF provides a great way for applications to present and interact with data. Elements

# November 4, 2007 8:52 AM
Leave a Comment

(required) 

(required) 

(optional)

(required) 

  
Enter Code Here: Required

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Page view tracker