How to get Zoom value in scroll viewer in C# wpf Kinect SDK 2.0? RRS feed

  • Question

  • I have recently started using the Kinect SDK 2.0 and am focusing on a zoom and pan functionality, as in the Control Basics-WPF sample.

    I have got the zoom and pan functionality up and running. The problem is that I wish to access the value of the amount of zoom which has been performed by the Pinch zoom gesture.

    Here is my xaml:

        <UserControl x:Class="ImageNav.NavigationImage"
            <Grid Grid.RowSpan="2">
                <ScrollViewer Name="scrollViewer" Grid.Row="0"
                              HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"
                              k:KinectRegion.IsHorizontalRailEnabled="true" k:KinectRegion.IsVerticalRailEnabled="true"
                    <Image Name="navigationImage" RenderTransformOrigin="0.5, 0.5" />
                <TextBox x:Name="ZoomTextBox" Grid.Row="1" TextWrapping="Wrap" Text="Zoom: 100%" IsEnabled="False" Panel.ZIndex="10" BorderThickness="0" HorizontalAlignment="Right" VerticalAlignment="Bottom" FontSize="20"/>

    I would have wanted there to be something like `k:KinectRegion.ZoomFactor`, but that isnt available. I've also tried to see what changes in the UI elements when I perform the zoom gesture, by writing the `Height` and `ActualHeight` properties of the `ScrollViewer scrollViewer` and `Image navigationImage` to a log file, but they show no change whatsoever.

    When I perform the zoom gesture, I would like to get the value of zoom i.e. the current height and width of the image with respect to the original height and width.
    Tuesday, February 3, 2015 12:38 PM


  • You might want to look deeper into how the scrollviewer works in WPF. I don't know the specifics but I am sure it doesn't change the physical size of the image, but modifies it's rendering properties of the ScrollViewer transform(zoom == scale). You can probably subscribe to an event whenever there is a change detected.

    Carmine Sirignano - MSFT

    Tuesday, February 3, 2015 6:10 PM