C# 作为根元素的面板导数
出于某种原因,我回到了SilverlightWindowsPhone7.x中的一个项目 所以我下载了VS2012 for WP,并在过去的工作解决方案中打开。 问题是,现在它不起作用了 当我启动调试时,emulator会抛出带有文本的异常:C# 作为根元素的面板导数,c#,silverlight,windows-phone-7,C#,Silverlight,Windows Phone 7,出于某种原因,我回到了SilverlightWindowsPhone7.x中的一个项目 所以我下载了VS2012 for WP,并在过去的工作解决方案中打开。 问题是,现在它不起作用了 当我启动调试时,emulator会抛出带有文本的异常: ExceptionObject {MS.Internal.WrappedException: The ItemsControl.ItemsPanelTemplate must have a derivative of Panel as the root el
ExceptionObject {MS.Internal.WrappedException: The ItemsControl.ItemsPanelTemplate must have a derivative of Panel as the root element. ---> System.InvalidOperationException: The ItemsControl.ItemsPanelTemplate must have a derivative of Panel as the root element.
at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
at MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize)
at System.Windows.FrameworkElement.MeasureOverride(Size availableSize)
at Microsoft.Phone.Controls.PivotItem.MeasureOverride(Size availableSize)
我想问题就在这里(当我评论下面的代码时,它正在工作)
我不太清楚那个异常是什么意思,有人能帮我解决一下吗
提前感谢此错误意味着您必须先定义一种面板类型,然后才能开始在
项目面板模板中执行任何操作。ScrollViewer
源于,而不是面板
尝试在ItemsPanelTemplate
中的ScrollViewer
周围添加Grid
、StackPanel
或Canvas
。该错误意味着您必须首先定义一种面板类型,然后才能开始在ItemsPanelTemplate
中执行任何操作。ScrollViewer
源于,而不是面板
尝试在ItemsPanelTemplate
中的ScrollViewer
周围添加Grid
、StackPanel
或Canvas
,好吧,thx用于回复,但此解决方案给了我一个新的例外:无法显式修改用作ItemsControl的ItemsPanel的面板的子集合。ItemsControl为面板生成子元素。也许本文可以帮助您?好吧,我想出来了,我用另一种方式实现了它,在uniformgrid上没有scrollviewer。Thx for your time:)好的,Thx for reply,但这个解决方案给了我一个新的例外:无法显式修改用作ItemsControl的ItemsPanel的面板的子集合。ItemsControl为面板生成子元素。也许本文可以帮助您?好吧,我想出来了,我用另一种方式实现了它,在uniformgrid上没有scrollviewer。感谢您的时间:)
<controls:PivotItem Header="{Binding Path=LocalizedResources.Categories, Source={StaticResource LocalizedStrings}}" Margin="0,12,0,0">
<ItemsControl x:Name="_categories" ItemsSource="{Binding CategoriesVM.Categories}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<ScrollViewer>
<local2:UniformGrid Rows="4" Columns="2"/>
</ScrollViewer>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid>
<Border Margin="9,0" Padding="0" BorderThickness="1" BorderBrush="White" Height="212" Width="210" Canvas.ZIndex="1">
<Image local:LowProfileImageLoader.UriSource="{Binding imgsrc}" Margin="0" Width="210" Height="210" />
</Border>
<Rectangle Width="210" Height="39" Canvas.ZIndex="2" Fill="#FF8DFFFA" VerticalAlignment="Bottom" Margin="0,0,0,10" Opacity="0.8" />
<TextBlock Text="{Binding name}" Canvas.ZIndex="4" VerticalAlignment="Bottom" Margin="25,0,0,17" Foreground="#FFCD1A1A" HorizontalAlignment="Left" />
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</controls:PivotItem>