ピボットを使用して画像を表示しようとしています。
しかし、コードを実行すると、デバッガーは次の行で中断します。
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>
「QueueingImages」は次のとおりです。
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");
}
}
誰かが私が間違っていることを指摘できますか?