如何在Windows Phone 8中为应用程序显示两列中的列表?
items.xaml.cs:
public async void Initi()
{
var itemsManagement = new ItemsManagement();
var itemList = await itemsManagement.GetAllItems();
var templist = from c in itemList.Data orderby c.Name, c.Id ascending select c;
NameList.ItemsSource = templist;
}
items.xaml:
<ListBox x:Name="NameList">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=Name}">
</TextBlock>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
此解决方案在一列中显示我的列表,我想在两列中显示
答案 0 :(得分:1)
使用LongListSelector,将LayoutMode设置为网格,将GridCellSize设置为页面宽度的一半。
<phone:LongListSelector
LayoutMode="Grid"
GridCellSize="200,20"
ItemsSource="{Binding Items}"
ItemTemplate="{StaticResource ItemTemplate}"
</phone:LongListSelector>
答案 1 :(得分:-1)
您是否尝试过以这种方式:
<ListBox x:Name="NameList">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Path=Name}" Width="200"/>
<TextBlock Text="{Binding Path=Id}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>