在 Windows Phone 8 的网格视图中显示列表 [英] Display a list in Grid view for windows phone 8

查看:34
本文介绍了在 Windows Phone 8 的网格视图中显示列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 Windows Phone 8 中为应用程序显示两列列表?

How Can I display a list in two columns for an application in windows phone 8?

items.xaml.cs:

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 :

items.xaml :

<ListBox x:Name="NameList">
       <ListBox.ItemTemplate>
            <DataTemplate>
                  <TextBlock Text="{Binding Path=Name}">
                  </TextBlock>
             </DataTemplate>
       </ListBox.ItemTemplate>
 </ListBox>

此解决方案将我的列表显示在一列中,我希望显示在两列中

This solution displays my list in one column, I would like a display in two columns

推荐答案

使用 LongListSelector,并设置 LayoutMode 到 Grid 和 GridCellSize 到页面宽度的一半.

Use a LongListSelector, and set LayoutMode to Grid and GridCellSize to half the page width.

<phone:LongListSelector
    LayoutMode="Grid"
    GridCellSize="200,20"
    ItemsSource="{Binding Items}"
    ItemTemplate="{StaticResource ItemTemplate}"
</phone:LongListSelector>

这篇关于在 Windows Phone 8 的网格视图中显示列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆