资产文件夹中的图像在UWP应用程序中不起作用

问题描述:

图像在MainPage中工作,但我正在尝试将其集成到导航面板Templete中并且图像没有显示出来。任何人都可以建议我可能是什么问题。

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.

Templete正在使用FRAMES,但这不应该是问题。

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

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>


我注意到你的页面在你的Pages / Go Nuts文件夹,因此您应该使用以下URI来获取图像。

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" />

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

使用< 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.