繁体   English   中英

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

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

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

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

得到这个例外

您需要在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>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM