2015-11-04 34 views
7

enter image description here圖像不能在UWP應用工作

的圖像是在工作的MainPage,但我想它集成在導航面板中Templete和圖像不顯示。任何人都可以告訴我可能是什麼問題。

Templete正在使用FRAMES,但這不應該成爲問題。

XAML代碼

<Button Grid.Column="0" Style="{StaticResource NavigationButtonStyle}"> 
       <StackPanel Orientation="Horizontal"> 
        <Image Source="Assets/donut-icon.png" Style="{StaticResource IconImageStyle}" /> 
        <TextBlock Text="Donut" Foreground="White" /> 
       </StackPanel> 
      </Button> 

樣式資源

<Style TargetType="Image" x:Key="IconImageStyle"> 
      <Setter Property="Height" Value="20" /> 
      <Setter Property="Width" Value="20" /> 
      <Setter Property="Margin" Value="0,0,10,0" /> 
     </Style> 

回答

14

我注意到,你的網頁是在「頁/發瘋」的文件夾,所以你應該使用以下URI來獲取圖像。

<Image Source="ms-appx:///Assets/donut-icon.png" /> 

或者

<Image Source="/Assets/donut-icon.png" /> 

在使用<Image Source="Assets/donut-icon.png" />將當前文件夾中搜索資源。但是當前文件夾中沒有這樣的資源,所以它不起作用。

+0

謝謝,它的工作! –

+0

@JayZuo如果它在Resources文件夾中呢?在DRAWABLE圖標中? –

+0

@JayceeEvangelista我不確定你的Resources文件夾和DRAWABLE圖標是什麼。如果您有任何問題,請隨時就您的問題的詳細情況提出一個新問題,以便我們可以進一步幫助您。 –