2014-10-27 50 views
0

我試圖插入一個圖像到我的Windows應用商店應用程序,它出現在XAML編輯器的設計時,但在運行時圖像不出現。<Image />在設計時顯示圖像,但不是在運行時;爲什麼?

我很確定我在這裏使用了正確的代碼,並且我已經將該徽標添加到了資產文件夾,但它仍然不會在運行時出現。如果我在代碼或資產文件夾中遇到錯誤,那麼它甚至不會出現在編輯器的設計階段,我認爲是什麼給了它?

Image not appearing in Windows Store App

XAML:

<Page 
    x:Class="AppName.MainPage" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:local="using:AppName" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    mc:Ignorable="d"> 

    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> 
     <Image Source="Assets\Logos\16380.png" 
       Stretch="None" 
       HorizontalAlignment="Left" 
       VerticalAlignment="Top" 
       Margin="120, 0, 0, 0" 
       /> 
    </Grid> 
</Page> 

回答

3

我已經成功地解決了這個問題。

將圖像插入到XAML中的頁面上時,需要在解決方案資源管理器中右鍵單擊圖像文件,單擊屬性,然後確保其「構建操作」設置爲「內容」,然後將「複製到輸出目錄」設置爲「 。您還需要使用正斜槓(/)而不是反斜槓()。

相關問題