windows-phone-7 - 为什么我从 LongListSelector 下降时收到 "well-formedness constraint: unique attribute spec"(0xc00cee3c) 错误

标签 windows-phone-7 inheritance silverlight-toolkit longlistselector

我正在尝试从 silverlight 工具包 LongListSelector 创建一个后代类。我们称它为 SimpleLonglistSelector。我从“Silverlight for Windows Phone Toolkit Source & Sample - Feb 2011.zip”开始

http://silverlight.codeplex.com/releases/view/60291

我创建了一个新类:

public class SimpleLongListSelector : LongListSelector
{
    public SimpleLongListSelector()
    {
        var itemsPanelTemplate = @"
            <ItemsPanelTemplate xmlns='http://schemas.microsoft.com/client/2007'>
                <toolkit:WrapPanel xmlns:toolkit='clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit' Orientation=""Horizontal""/>
            </ItemsPanelTemplate>";

        this.GroupItemsPanel = (ItemsPanelTemplate)XamlReader.Load(itemsPanelTemplate);

        var groupItemTemplate = @"
            <DataTemplate xmlns='http://schemas.microsoft.com/client/2007'>
                <Border Width=""99"" Height=""99"" Background=""{StaticResource PhoneAccentBrush}"" Margin=""6"" IsHitTestVisible=""{Binding HasItems}"">
                    <TextBlock Text=""{Binding Key}"" 
                                           FontFamily=""{StaticResource PhoneFontFamilySemiBold}""
                                           FontSize=""36""
                                           Margin=""{StaticResource PhoneTouchTargetOverhang}""
                                           Foreground=""{StaticResource PhoneForegroundBrush}""                                        
                                           VerticalAlignment=""Bottom""/>
                </Border>
            </DataTemplate>";

        this.GroupItemTemplate = (DataTemplate)XamlReader.Load(groupItemTemplate);

        var groupHeaderTemplate = @"
            <DataTemplate xmlns='http://schemas.microsoft.com/client/2007'>
                <Border Background=""Transparent"">
                    <Border Background=""{StaticResource PhoneAccentBrush}"" Width=""75"" Height=""75"" HorizontalAlignment=""Left"">
                        <TextBlock Text=""{Binding Path=Key}"" 
                                               Foreground=""{StaticResource PhoneForegroundBrush}"" 
                                               Style=""{StaticResource PhoneTextExtraLargeStyle}""
                                               VerticalAlignment=""Bottom""/>
                    </Border>
                </Border>
            </DataTemplate>";

        this.GroupHeaderTemplate = (DataTemplate)XamlReader.Load(groupHeaderTemplate);

        var itemTemplate = @"
            <DataTemplate xmlns='http://schemas.microsoft.com/client/2007'>
                <TextBlock Text=""{Binding Title}"" FontSize=""30""/>
            </DataTemplate>";

        this.ItemTemplate = (DataTemplate)XamlReader.Load(itemTemplate);
    }
}

然后我将它添加到 LongListSelector 示例中,与所有其他长列表选择器在同一个轴中:
            <controls:PivotItem Header="SLLS">
                <local:SimpleLongListSelector x:Name="simple" />
            </controls:PivotItem>

然后我添加它的源与 LoadLinqMovies() 中的电影源相同
        simple.ItemsSource = moviesByCategory;

然后运行代码(我知道它看起来不漂亮,那是因为绑定(bind)设置不正确,我这样做是为了让你知道它不是数据。如果你愿意,你可以这样做:
        simple.ItemsSource = movies.GroupBy((m) => m.Title[0]).Select((c) => new PublicGrouping<char, Movie>(c));

看起来我希望它看起来。

好吧,无论哪种情况,这都按预期工作,除非我单击组标题。 (任何 [默认为蓝色] 方 block )。我得到一个
WrappedException

错误信息是:
0xc00cee3c

我认为这意味着:
well-formedness constraint: unique attribute spec

我认为我没有唯一性问题。我究竟做错了什么?

最佳答案

如果您使用 7.1 工具包中的 LongListSelector,可在 http://silverlight.codeplex.com/releases/view/71550 找到,您的示例代码按上面列出的方式工作。这一定是原始 LLS 中的一些错误......

关于windows-phone-7 - 为什么我从 LongListSelector 下降时收到 "well-formedness constraint: unique attribute spec"(0xc00cee3c) 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6880464/

相关文章:

.net - 设计可移植到 iOS/Monotouch 的 Windows Phone 游戏的技巧

c# - 如何恢复此 rss 提要的图像?

c++ - 从派生类访问基类的 protected 数据成员

PHP - 给定 Boo 的可捕获 fatal error : Argument 1 passed to Too must be an instance of Foo, 实例?

windows-phone-7 - ListPicker - 如何在全页 View 打开时显示当前选择

silverlight - 在 Windows Phone 7 中本地化图像

c# - 读取和使用 XML 文件作为数据库 - Windows Phone 7 应用程序

java - 如何使用 JPA 继承将多个子实体插入到同一个父实体中?

Silverlight 验证不适用于数据注释

windows-phone-7 - 带有 Windows Phone 工具包的多目标 WP7.1/WP8 应用程序 (Panorama/LongListSelector)