.DLL中出现“System.InvalidCastException”类型的异常,但未在用户代码中处理

时间:2013-10-18 16:37:53

标签: c# silverlight xaml windows-phone-7 windows-phone

当我放大图像时,我在运行时收到此错误消息。

这是XAML代码

<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

1 个答案:

答案 0 :(得分:2)

您需要在xaml中定义RenderTransform

<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>