C# 在windows phone 8的网格视图中显示列表
如何在windows phone 8中以两列形式显示应用程序的列表 items.xaml.cs:C# 在windows phone 8的网格视图中显示列表,c#,xaml,windows-phone-8,C#,Xaml,Windows Phone 8,如何在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 a
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>
此解决方案将我的列表显示在一列中,我希望显示在两列中您是否尝试过这样做:
<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>
使用LongListSelector,并设置为Grid和页面宽度的一半
<phone:LongListSelector
LayoutMode="Grid"
GridCellSize="200,20"
ItemsSource="{Binding Items}"
ItemTemplate="{StaticResource ItemTemplate}"
</phone:LongListSelector>
你试过什么?请阅读在DataTemplate中创建网格:如何避免重复数据?