Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Images from Assets Folder are not working in UWP app

enter image description here

The Images are working in the MainPage, but I'm trying to Integrate it in an Navigational Panel Templete and the images don't show up. Can anyone suggest me what might be the problems.

The Templete's making use of FRAMES but that should not be the issues.

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>

Styles 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>
like image 850
Hemant-Webo Avatar asked Nov 04 '15 07:11

Hemant-Webo


People also ask

How do I upload an image to UWP?

Go to tool box and drag and drop the image into the designer page. In the solution explorer go to assets and right click. Then click add -> existing item. Browse the required file.

How do I add UWP to Visual Studio?

If you don't see the Blank App (Universal Windows) project template, click the Install more tools and features link. The Visual Studio Installer launches. Choose the Universal Windows Platform development workload, and then select Modify. Give the project a name, HelloWorld, and choose Create.


1 Answers

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

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

Or

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

While using <Image Source="Assets/donut-icon.png" /> it will search resource in current folder. But there is no such resource in current folder, so it won't work.

like image 147
Jay Zuo Avatar answered Sep 23 '22 22:09

Jay Zuo