2013-03-18 91 views
1

如何在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 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> 

該方案顯示在一列我的名單,我想在兩列

+1

你有什麼試過的?請閱讀[this](http://mattgemmell.com/2008/12/08/what-have-you-tried/) – 2013-03-18 14:55:23

+0

在您的DataTemplate中創建一個網格:http://msdn.microsoft.com/en-us /library/system.windows.controls.grid(v=vs.95).aspx – Fabrice 2013-03-18 15:24:55

+0

如何避免重複數據? – user2169047 2013-03-18 19:12:08

回答

-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> 
1

使用LongListSelector,並將LayoutMode設置爲網格,將GridCellSize設置爲頁面寬度的一半。

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