<;中的MS.Internal.WrappedException;数据透视图>;.项目来源

本文关键字:gt 项目 透视图 WrappedException lt 中的 MS Internal 数据 | 更新日期: 2023-09-27 17:59:44

我正在尝试使用pivot来查看图像
但是当我运行代码时,调试器在以下行中断:

MainViewer.ItemsSource = QueueingImages;

并抛出了一个奇怪的异常:

An exception of type 'MS.Internal.WrappedException' occurred in System.Windows.ni.dll and wasn't handled before a managed/native boundary

这是我使用的xaml:

<phone:Pivot Grid.Row="1" Name="MainViewer">
    <phone:Pivot.HeaderTemplate>
        <DataTemplate>
            <TextBlock Text="" FontSize="0" />
        </DataTemplate>
    </phone:Pivot.HeaderTemplate>
    <phone:Pivot.ItemTemplate>
        <DataTemplate>
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*" />
                        <RowDefinition Height="10" />
                    </Grid.RowDefinitions>
                    <Image Source="{Binding IMGSource}" Stretch="Uniform" Grid.Row="0">
                        <toolkit:GestureService.GestureListener>
                            <toolkit:GestureListener Flick="{Binding ImageFlick}"
                                                 DragDelta="{Binding ImagePan}"
                                                 PinchDelta="{Binding ImageZoom}"
                                                 Tap="{Binding ImageTap}"
                                                 DoubleTap="{Binding ImageDoubleTap}"
                                                 />
                        </toolkit:GestureService.GestureListener>
                    </Image>
                    <ProgressBar Grid.Row="1" Value="{Binding DownloadPercentage}" Maximum="100" Minimum="0" SmallChange="1" Visibility="{Binding IsCompleted}"/>
                </Grid>
        </DataTemplate>
    </phone:Pivot.ItemTemplate>
</phone:Pivot>

"排队图像"是:

private ObservableCollection<ImageView> QueueingImages

这是ImageView类:

class ImageView
{
    public ImageView(String id)
    {
        Id = id;
    }
    public String Id { get; private set; }
    public ImageSource IMGSource { get; private set; }
    public int DownloadPercentage { get; set; }
    public Visibility IsCompleted { get; set; }
    public event EventHandler Flicked;
    /*
    Flick="{Binding ImageFlick}"
    DragDelta="{Binding ImagePan}"
    PinchDelta="{Binding ImageZoom}"
    Tap="{Binding ImageTap}"
    DoubleTap="{Binding ImageDoubleTap}"
    */
    public void SetSource(System.IO.Stream s)
    {
        BitmapImage bi = new BitmapImage();
        bi.SetSource(s);
        IMGSource = bi;
    }
    public void ProgressHandler(object sender, DownloadProgressChangedEventArgs e)
    {
        DownloadPercentage = e.ProgressPercentage;
    }
    /////// Image Controls
    public void ImageFlick(object sender, FlickGestureEventArgs e)
    {
        // Pass out Event
        if (Flicked != null)
            Flicked(sender, e);
    }
    public void ImagePan(object sender, DragDeltaGestureEventArgs e)
    {
        System.Diagnostics.Debug.WriteLine("Panning");
    }
    public void ImageZoom(object sender, PinchGestureEventArgs e)
    {
        System.Diagnostics.Debug.WriteLine("Zooming");
    }
    public void ImageTap(object sender, GestureEventArgs e)
    {
        System.Diagnostics.Debug.WriteLine("Tapped");
    }
    public void ImageDoubleTap(object sender, GestureEventArgs e)
    {
        System.Diagnostics.Debug.WriteLine("Double Tapped");
    }
}

有人能指出我做错了什么吗?

<;中的MS.Internal.WrappedException;数据透视图>;.项目来源

好吧,我想明白了
错误是由以下代码引起的

<toolkit:GestureService.GestureListener>
     <toolkit:GestureListener Flick="{Binding ImageFlick}"
         DragDelta="{Binding ImagePan}"
         PinchDelta="{Binding ImageZoom}"
         Tap="{Binding ImageTap}"
         DoubleTap="{Binding ImageDoubleTap}"
     />
</toolkit:GestureService.GestureListener>

我似乎不能在toolkit:GestureListener下使用绑定
我删除了绑定,一切都很顺利:)