资产文件夹中的图像在UWP应用程序中不起作用 [英] Images from Assets Folder are not working in UWP app

查看:165
本文介绍了资产文件夹中的图像在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.

这篇关于资产文件夹中的图像在UWP应用程序中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆