【问题标题】:Wrappanel in ItemsControl.ItemsPanel throws XamlParseExceptionItemsControl.ItemsPanel 中的 Wrappanel 引发 XamlParseException
【发布时间】:2023-03-23 07:12:01
【问题描述】:

在我的 wp8 应用程序中,我展示了一些内容(例如图像)。我使用 LongListSelector,并且在每个 LLS 的项目中都有带有图像集合的 ItemsControl。我想在一行中显示两个图像,所以我使用了一个包装板。但它会在用户控件页面的InitializeComponent() 行中引发 XamlParseException。没有 wrappanel 一切正常。代码在这里

            <ItemsControl HorizontalAlignment="Center" ItemsSource="{Binding Vkontakte.Attachments.Photos}" >
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <toolkit:WrapPanel Height="100" Width="100" />
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>

            <ItemsControl.ItemTemplate>
                <DataTemplate>
                <Image Margin="0,10,0,0" >
                    <Image.Source>
                        <BitmapImage UriSource="{Binding Src}" CreateOptions="BackgroundCreation" />
                    </Image.Source>
                </Image>
            </DataTemplate>
            </ItemsControl.ItemTemplate>
        </ItemsControl>

也许问题在于ItemsControlStackPanel 中?

【问题讨论】:

  • 例外是?内在的例外?堆栈跟踪?没有,我们所能做的就是猜测......要么 1. 您的工具包的 xmlns 格式错误 2. 未找到命名空间中定义的程序集 3. 加载到设计器的版本与交付到 bin 文件夹的版本不同 4 . WrapPanel 的构造函数抛出异常。前三个可以通过打开融合绑定并仔细检查运行时发生的情况来发现,最后一个通过在 WrapPanel 的构造函数中使用断点将第二个 Visual Studio 实例附加到第一个实例。

标签: c# silverlight windows-phone-7 itemscontrol wrappanel


【解决方案1】:

由于您的 ItemsSource 绑定,我会抛出异常。如果 Vkontakte 不是您的数据上下文中的对象,那么您可能需要查看您绑定的对象。它需要是某种对象的集合。

【讨论】:

  • 它可能仍然是真的。如果为 null,则可能有意外行为。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-07-16
  • 1970-01-01
  • 2012-05-22
  • 1970-01-01
  • 2019-01-26
相关资源
最近更新 更多