开发者

Why am I getting a "well-formedness constraint: unique attribute spec" (0xc00cee3c) error when I descend from LongListSelector

I'm trying to create a descendant class from the silverlight toolkit LongListSelector. Let's call it SimpleLonglistSelector. I started from the "Silverlight for Windows Phone Toolkit Source & Sample - Feb 2011.zip"

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

I created a new class:

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);
    }
}

Then I added it to the LongListSelector example, in the same pivot as all of the other long list selectors:

            <controls:PivotItem Header="SLLS">
                <local:SimpleLongListSelector x:Name="simple" />
            </controls:PivotItem>

Then开发者_运维知识库 I added it's source to be the same as the movies source in the LoadLinqMovies()

        simple.ItemsSource = moviesByCategory;

Then run the code (I know it doesn't look pretty, that's because the bindings haven't been set up right, I do that so you know it's not the data. If you'd like, you can do it like this:

        simple.ItemsSource = movies.GroupBy((m) => m.Title[0]).Select((c) => new PublicGrouping<char, Movie>(c));

That looks like I want it to look.

Well, in either case, this works as expected, except when I click on a group header. (any of the [by default blue] squares). I get a

WrappedException

The error message is:

0xc00cee3c

Which I think means:

well-formedness constraint: unique attribute spec

I don't think I've got a uniqueness problem. What am I doing wrong?


If you use the LongListSelector from the 7.1 toolkit, found at http://silverlight.codeplex.com/releases/view/71550, your sample code works as listed above. This must have been some bug in the original LLS...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜