我试图从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;
然后运行代码(我知道它看起来不漂亮,这是因为绑定没有设置正确,我这样做,所以你知道这不是数据,如果你愿意,你可以这样做:
simple.ItemsSource = movies.GroupBy((m) => m.Title[0]).Select((c) => new PublicGrouping<char,Movie>(c));
看起来我想要看它.
那么,无论哪种情况,这都是按预期的方式工作,除非我点击组头. (任何[默认蓝色]方块).我得到了
WrappedException
错误信息是:
0xc00cee3c
我认为是什么意思:
well-formedness constraint: unique attribute spec
我不认为我有一个唯一性的问题.我究竟做错了什么?
如果您使用7.1工具包中的LongListSelector,可以在
http://silverlight.codeplex.com/releases/view/71550找到,您的示例代码如上所列.这一定是原来LLS中的一些bug
原文链接:/windows/371322.html