2012-02-05 55 views
1

我試圖將一些圖像放入集線器瓦片作爲窗口手機7設計,但我發現即使我完全按照電子書,但仍然無法將圖像放入其中。 任何人都可以嗎?無法將圖像放入集線器瓦片

XAML代碼

<ListBox Grid.Row="0" x:Name="tileList"> 
        <ListBox.ItemsPanel> 
         <ItemsPanelTemplate> 
          <toolkit:WrapPanel Orientation="Horizontal"/> 
         </ItemsPanelTemplate> 
        </ListBox.ItemsPanel> 
        <ListBox.ItemTemplate> 
         <DataTemplate> 
          <toolkit:HubTile Title="{Binding Title}" Margin="3" Notification="{Binding Notification}" 
             DisplayNotification="{Binding DisplayNotification}" Message="{Binding Message}" 
              GroupTag="{Binding GroupTag}" Source="{Binding ImageUri}"> 
          </toolkit:HubTile> 
         </DataTemplate> 
        </ListBox.ItemTemplate> 
       </ListBox> 

代碼後面

List<TileItem> tileItems = new List<TileItem>() 
      { 
       new TileItem() 
       { 
        ImageUri="/Images/logo.png", Title="Work Hard", Notification = "Work Hard", GroupTag="TileGroup" 
       }, 
       new TileItem() 
       { 
        ImageUri="/Images/Hard.jpg", Title="Work Smart", Notification = "Work Smart", GroupTag="TileGroup" 
       }, 
       new TileItem() 
       { 
        ImageUri="/Images/Hard.jpg", 
        Title = "Play Smart", 
        Message = "Look Smart" 
       }, 
       new TileItem() 
       { 
        ImageUri="/Images/Hard.jpg", 
        Title = "Sleep Smart", 
        Message = "Sleep Smart" 
       }, 
       new TileItem() 
       { 
        ImageUri="/Images/Hard.jpg", 
        Title = "Sleep Hard", 
        Message = "Sleep Hard" 
       }, 
       new TileItem() 
       { 
        ImageUri="/Images/Hard.jpg", Title="Play Hard", Notification = "Play Hard", GroupTag="TileGroup" 
       } 
      }; 

對於其是

public class TileItem 
    { 
     public string ImageUri 
     { 
      get; 
      set; 
     } 

     public string Title 
     { 
      get; 
      set; 
     } 

     public string Notification 
     { 
      get; 
      set; 
     } 

     public bool DisplayNotification 
     { 
      get 
      { 
       return !string.IsNullOrEmpty(this.Notification); 
      } 
     } 

     public string Message 
     { 
      get; 
      set; 
     } 

     public string GroupTag 
     { 
      get; 
      set; 
     } 
    } 

任何類PLS。謝謝

+0

圖像被保存爲內容? – Ku6opr 2012-02-05 14:57:52

+0

圖像被添加到/圖像 – 2012-02-05 18:08:02

+0

我的意思是內容/資源選項:) – Ku6opr 2012-02-06 08:07:33

回答

1

根據你的路徑判斷,我會說它的「構建行動」。您可能想要檢查您嘗試顯示的圖像是否將其「Build Action」設置爲內容。

+0

感謝您的回覆。 我查過了。其構建行爲已經設置爲資源。 非常感謝。那麼解決問題的默認是改變內容? – 2012-02-05 18:17:54

+2

或設置圖像路徑,如「yourassemblyname; component/Images/Hard.jpg」 – Ku6opr 2012-02-06 08:07:20

+1

@CarsonLee默認情況下,它被添加爲資源。但出於性能目的,您應該將其更改爲內容並遵循您在問題中使用的路徑。原因是,當您將它作爲資源添加到您的應用程序時,它會存儲在您應用程序的dll文件中,從而增加您的應用程序加載的時間。 – loyalpenguin 2012-02-06 15:39:59