我正在尝试使用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>
&#34; QueueingImages&#34;是:
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");
}
}
有人可以指出我做错了什么吗?
答案 0 :(得分:0)
好吧,我明白了。
该错误是由以下代码引起的。
<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
下使用绑定
我删除了绑定,一切都运行良好:)