我正在动态地将全景项目添加到全景控件中,它们添加成功没有任何问题
但是当我尝试将列表框添加到全景项目时,它给出了错误。我也看不到异常,应用程序自动关闭,之后我看到了模拟器主屏幕。
以下是我为创建全景项目和列表框而编写的代码
lstAnniversaries = new ListBox()
lstAnniversaries.Width = 420;
lstAnniversaries.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
lstAnniversaries.Foreground = new SolidColorBrush(FacebookQueries.GetColorFromHexString("#000000"));
lstAnniversaries.Background = new SolidColorBrush(FacebookQueries.GetColorFromHexString("#ffffff"));
lstAnniversaries.Tap += new EventHandler<System.Windows.Input.GestureEventArgs>(lstUpcoming_Tap);
lstAnniversaries.ItemTemplate = (DataTemplate)XamlReader.Load(@"<DataTemplate xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"">
<Grid Height=""100"" Margin=""0,0,0,0"">
<Grid.ColumnDefinitions>
<ColumnDefinition Width=""90"" />
<ColumnDefinition Width=""210"" />
<ColumnDefinition Width=""*"" />
</Grid.ColumnDefinitions>
<Image Source=""{Binding ImageSource}"" Height=""90"" Width=""90"" Margin=""0,0,11,0"" />
<StackPanel Grid.Column=""1"" Margin=""0,10,0,0"">
<TextBlock Text=""{Binding NameSource}"" Style=""{StaticResource ProfileNameStyleForTextBlock}"" />
<StackPanel Orientation=""Horizontal"" Margin=""0,-2,0,0"">
<TextBlock Text=""{Binding EventName}"" Foreground=""#000000"" Style=""{StaticResource EventNameStyleForTextBlock}"" />
<TextBlock Text=""{Binding EventDate}"" Foreground=""{Binding EventColor}"" Style=""{StaticResource EventDateStyleForTextBlock}"" />
</StackPanel>
</StackPanel>
<Button VerticalAlignment=""Center"" Height=""Auto"" Name=""btnAnniversary"" Width=""75"" Margin=""5,0,0,0"" HorizontalAlignment=""Left"" Visibility=""{Binding EllipseStatus}"" Tag=""{Binding BindsDirectlyToSource=True}"" Click=""btnAnniversary_Click"" Canvas.ZIndex=""1"" Grid.Column=""2"">
<Image Source=""/GiftGiv;component/Assets/bubble.png"" />
</Button>
</Grid>
</DataTemplate>");
pan_anniversaries = new PanoramaItem();
pan_anniversaries.HeaderTemplate = (DataTemplate)XamlReader.Load(@"<DataTemplate xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml""><TextBlock Text=""anniversaries"" FontSize=""54"" Foreground=""Black"" Margin=""-10,0,0,0""></TextBlock></DataTemplate>");
Grid grd = new Grid();
grd.Children.Add(lstAnniversaries);
pan_anniversaries.Content = grd;
PanoramaControl.Items.Add(pan_anniversaries);
编辑:
输出窗口文本
A first chance exception of type 'System.InvalidOperationException' occurred in System.Core.dll
A first chance exception of type 'System.InvalidOperationException' occurred in System.Core.dll
Step into: Stepping over method without symbols 'System.Reflection.RuntimeMethodInfo.InternalInvoke'
Step into: Stepping over method without symbols 'System.Reflection.MethodBase.Invoke'
Step into: Stepping over method without symbols 'System.Delegate.DynamicInvokeOne'
Step into: Stepping over method without symbols 'System.MulticastDelegate.DynamicInvokeImpl'
Step into: Stepping over method without symbols 'System.Delegate.DynamicInvoke'
Step into: Stepping over method without symbols 'System.Windows.Threading.DispatcherOperation.Invoke'
Step into: Stepping over method without symbols 'System.Windows.Threading.Dispatcher.Dispatch'
Step into: Stepping over method without symbols 'System.Windows.Threading.Dispatcher.OnInvoke'
Step into: Stepping over method without symbols 'System.Windows.Hosting.CallbackCookie.Invoke'
Step into: Stepping over method without symbols 'System.Windows.Hosting.DelegateWrapper.InternalInvoke'
Step into: Stepping over method without symbols 'System.Windows.RuntimeHost.ManagedHost.InvokeDelegate'
A first chance exception of type 'System.Exception' occurred in System.Windows.dll
A first chance exception of type 'MS.Internal.WrappedException' occurred in System.Windows.dll
A first chance exception of type 'MS.Internal.WrappedException' occurred in System.Windows.dll
A first chance exception of type 'MS.Internal.WrappedException' occurred in System.Windows.dll
A first chance exception of type 'MS.Internal.WrappedException' occurred in System.Windows.dll
A first chance exception of type 'MS.Internal.WrappedException' occurred in System.Windows.dll
A first chance exception of type 'System.Exception' occurred in System.Windows.dll
A first chance exception of type 'MS.Internal.WrappedException' occurred in System.Windows.dll
A first chance exception of type 'MS.Internal.WrappedException' occurred in System.Windows.dll
A first chance exception of type 'MS.Internal.WrappedException' occurred in System.Windows.dll
A first chance exception of type 'MS.Internal.WrappedException' occurred in System.Windows.dll
A first chance exception of type 'MS.Internal.WrappedException' occurred in System.Windows.dll
The thread '<No Name>' (0xf640c32) has exited with code 0 (0x0).
The thread '<No Name>' (0xf450ca6) has exited with code 0 (0x0).
The thread '<No Name>' (0xf050d2e) has exited with code 0 (0x0).
The thread '<No Name>' (0xf820cda) has exited with code 0 (0x0).
The thread '<No Name>' (0xecb0e52) has exited with code 0 (0x0).