Images from the Assets folder do not work in the UWP application

enter image description here

Images work in MainPage, but I'm trying to integrate it into the Templete navigation bar and the images are not displayed. Can someone tell me what problems might be.

The Templete uses FRAMES, but this should not be a problem.

XAML Code

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

  <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> 
+7
image windows-phone uwp xaml frame
source share
1 answer

I noticed that your page is in your "Pages / Go Nuts" folder, so you should use the following URI to get the image.

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

or

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

When using <Image Source="Assets/donut-icon.png" /> it will search for the resource in the current folder. But there is no such resource in the current folder, so it will not work.

+14
source share

All Articles