Rizwan Qureshi
Rizwan Qureshi

Reputation: 592

An exception of type 'System.InvalidCastException' occurred in .DLL but was not handled in user code

I am getting this error message at runtime when I zoom in an Image.

here is XAML code

<Grid x:Name="LayoutRoot" Background="Transparent">
        <toolkit:GestureService.GestureListener>
            <toolkit:GestureListener 
                PinchStarted="OnPinchStarted"
                PinchDelta="OnPinchDelta"
                DragDelta="OnDragDelta"
                Flick="GestureListener_Flick">
            </toolkit:GestureListener>
        </toolkit:GestureService.GestureListener>
        <Image x:Name="ImgZoom" Source="Image.jpg" HorizontalAlignment="Left" Width="480" Height="770" Stretch="Fill"  Margin="0,0,0,0" VerticalAlignment="Top"/>
</Grid>

Getting this exception

Upvotes: 0

Views: 2737

Answers (1)

Shawn Kendrot
Shawn Kendrot

Reputation: 12465

You need to define the RenderTransform within your xaml

<Image x:Name="ImgZoom" Source="Image.jpg" HorizontalAlignment="Left" Width="480" Height="770" Stretch="Fill"  Margin="0,0,0,0" VerticalAlignment="Top">
    <Image.RenderTransform>
        <CompositeTransform/>
    </Image.RenderTransform>
</Image>

Upvotes: 2

Related Questions