@H_
403_0@
在工具包LongListSelector中,曾经有一个
属性IsFlatList需要设置为true才能
显示平面列表而不进行任何分组.但是在手机控件中提供的LongListSelector中,缺少此
属性.这就是我在做的事情
<phone:LongListSelector Name="myList" IsGroupingEnabled="False" LayoutMode="List" ItemsSource="{Binding Source ={StaticResource SortedList} }" CacheMode="BitmapCache" >
<phone:LongListSelector.ItemTemplate>
<DataTemplate>
<components:MyControl CacheMode="BitmapCache" MyItem="{Binding}"/>
</DataTemplate>
</phone:LongListSelector.ItemTemplate>
</phone:LongListSelector>
如果我将控件更改为ListBox并删除LongListSelector特定属性,那么它将显示我的列表.
有人可以告诉我我错过了什么吗?
我正在关注LongListSelector的this(备注)文档
在LongListSelector的Windows Phone 8版本中,将LayoutMode设置为List并将IsGroupingEnabled设置为false,应将数据绑定数据
显示为平面列表,如WP7 Toolkit版本的控件.
例如,
给定实体类
public class Entity
{
public string Name
{
get;
set;
}
public string Info
{
get;
set;
}
public int ID
{
get;
set;
}
}
我需要做的就是在我的页面上创建一个ObservableCollection实体并将其绑定到我的LongListSelector(命名列表)的itemsource.
ObservableCollection<Entity> data = new ObservableCollection<Entity>();
list.ItemsSourdce = data;
然后我创建实体并将它们添加到集合中.
这是我的LongListSelector的XAML:
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,12,0">
<phone:LongListSelector Name="list" HorizontalAlignment="Left" Height="609" VerticalAlignment="Top" Width="456" LayoutMode="List" IsGroupingEnabled="False" >
<phone:LongListSelector.ItemTemplate>
<DataTemplate>
<StackPanel VerticalAlignment="Top">
<TextBlock FontWeight="Bold" Text="{Binding Name}" />
<TextBlock Text="{Binding Info}" />
</StackPanel>
</DataTemplate>
</phone:LongListSelector.ItemTemplate>
</phone:LongListSelector>
</Grid>