2014-11-25 105 views
3

我是WP8的新手。ListView在Windows Phone 8.1中的圖像

我有一個應用程序。

它進行Web API調用。

我得到一個項目列表。

我想顯示這個項目列表給用戶,左邊有一個圖標。

我想我應該使用ListView控件。

我花了很長時間試圖找到一個簡單的例子,但不能。

所以,要麼:

  1. 我是一個白癡
  2. 會有人給我一個鏈接就如何做到這一點
  3. 有人將發佈一個簡單的例子
  4. 我需要買不錯的WP8書(不過我還得等上幾天才能發貨)

我希望有人會回答3.我會跟進4.是的,我我相信我是1

UPDATE:

這是我的標記:

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"> 
     <ListBox Name="lstPremises" 
      ItemsSource="{Binding Items}" FontFamily="{StaticResource PivotHeaderItemFontFamily}" 
        Background="{StaticResource AppBarItemBackgroundThemeBrush}"> 
      <ListBox.ItemTemplate> 
       <DataTemplate> 
        <Grid> 
         <Grid.ColumnDefinitions> 
          <ColumnDefinition Width="Auto"></ColumnDefinition> 
          <ColumnDefinition Width="*"></ColumnDefinition> 
         </Grid.ColumnDefinitions> 
         <Image Grid.Column="0" Margin="12" Height="50" Width="50" Source="Images/Number-5-icon.png" ></Image> 
         <TextBlock Grid.Column="1" FontSize="36" Text="{Binding Caption}" TextWrapping="Wrap" FontFamily="Global User Interface"></TextBlock> 
        </Grid> 
       </DataTemplate> 
      </ListBox.ItemTemplate> 
     </ListBox> 
    </Grid> 

這是我的後臺代碼:

public class Item 
{ 
    public string Caption; 
} 
public sealed partial class Management : Page 
{ 
    public Management() 
    { 
     this.InitializeComponent(); 

     List<Item> test = new List<Item>(); 
     Item item = new Informed.Item(); 
     item.Caption = "Test One"; 
     test.Add(item); 
     Item item2 = new Informed.Item(); 
     item2.Caption = "Test Two"; 
     test.Add(item2); 
     lstPremises.ItemsSource = test; 
    } 
} 

,這是截圖:

enter image description here

回答

3

你可以從這裏 http://visualstudiomagazine.com/articles/2014/07/01/gridview-and-listview-controls.aspx 或該鏈接的工作示例,這些也都爲我工作 http://channel9.msdn.com/Series/Building-Apps-for-Windows-Phone-8-1/04 :第二個是視頻教程例子hopfully你會得到它

+0

您好,感謝響應。這些是我以前看過的兩個鏈接。該視頻令人沮喪。我想讓他們明白這一點。我複製並粘貼的示例代碼(來自其他鏈接),並提出錯誤。而且,它似乎被混淆了。我確信有很多屬性/樣式可以添加到列表視圖中,但我不想一次查看它們。我只想要一個簡單的代碼示例。我使用關聯的圖像將C#項添加到我的列表視圖中。這就是我想要的一個階段:) – 2014-11-25 10:17:53

+1

檢查此鏈接的代碼 https://github.com/MvvmCross/NPlus1DaysOfMvvmCross/tree/master/N-16-CollectABull-Part5 – 2014-11-25 10:23:20

+0

嗨,剛剛一直在通過這一切。我正在看列表框的例子...我應該仍然使用列表框,因爲視頻鏈接暗示我不應該?此外,雖然我有圖標顯示我沒有數據顯示。我會更新我的問題,向您展示這一點。謝謝 – 2014-11-25 11:14:41