How to reset the image after zoom is done?

Oct 29, 2010 at 2:49 PM
Edited Oct 29, 2010 at 3:00 PM

Hello All:

I'm using an image with the pinch zoom effect.

I've a situation where user clicks on a image of a images list, the user is shown the selected image where he can have all the Multi-touch effects.

The XAML code is as follows:

<Image x:Name="zoomImage" Grid.Row="1" Height="400" Width="400" >
                <i:Interaction.Behaviors>
                    <tb:MultiTouchBehavior
                        AreFingersVisible="False"
                        IsDebugModeActive="False"
                        IsMockActive="True"
                        IsRotateEnabled="False"
                        IsScaleEnabled="True"
                        IsTranslateXEnabled="True"
                        IsTranslateYEnabled="True"
                        MaximumScale="10"
                        MinimumScale="0.5"/>
                </i:Interaction.Behaviors>
            </Image>

He can close the image and select another image. When I'm loading the second image, it loads that image, but the zoomed ill remain the same. How can I reset the image to default view when I load the it.

Oct 29, 2010 at 3:12 PM

Hi,

if you use the Behavior available in the source code samples (check the SilverlightWP7MultiTouchSample project), just use this code to reset the original default view:

//Reset the image
var multiTouchBehaviors = System.Windows.Interactivity.Interaction.GetBehaviors(item1).OfType<MultiTouchBehavior>();
if (multiTouchBehaviors.Count() > 0)
    multiTouchBehaviors.First().Move(new Point(200, 150), 45, 100);
Oct 29, 2010 at 4:01 PM
Edited Oct 29, 2010 at 4:03 PM

Hi davidezordan,

Thank you very much. It worked and you Rock man.

I did it in  the following way:

var multiTouchBehaviors = System.Windows.Interactivity.Interaction.GetBehaviors(this.zoomImage).OfType<MultiTouchBehavior>();
            if (multiTouchBehaviors.Count() > 0)
                multiTouchBehaviors.First().Reset();

Oct 29, 2010 at 4:16 PM

Thank you dude, glad to help ;)