C# UWP应用程序不显示图像

C# UWP应用程序不显示图像,c#,uwp,win-universal-app,uwp-xaml,C#,Uwp,Win Universal App,Uwp Xaml,我在显示图像时遇到了一个小问题 图像位于“资源”文件夹中。 以下是我的XAML代码: <Page x:Class="MyApp.WelcomeScreen" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:MyApp" x

我在显示图像时遇到了一个小问题

图像位于“资源”文件夹中。 以下是我的XAML代码:

<Page
    x:Class="MyApp.WelcomeScreen"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:MyApp"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"  Width="800" Height="480" RequestedTheme="Dark">

    <Grid Background="#C4043F">
        <Image Name="MyPicture" Source="/Assets/LOGO.png" HorizontalAlignment="Left" VerticalAlignment="Top"/>
   </Grid>
</Page>
我已经尝试了这里描述的一切:

我遗漏了什么?

按照以下步骤操作:

1) 构建操作设置为内容

2) 并尝试在图像属性中设置“始终**复制到输出目录”


要么是相对路径错误,要么图像不是
嵌入资源
。事实上,如果图像路径正确,只需设置就可以了路径确实有问题。如果我添加,它就可以工作。Visual Studio中的项目名和保存项目的文件夹有不同的名称。可能是我这是困扰Visual Studio的问题…请尝试
Source=“ms-appx:///YourProjectName/Assets/LOGO.png“
它是网格中的唯一项目?请尝试提供高度和宽度以进行检查。“检查生成操作是否设置为内容,并尝试在图像属性中设置“始终复制到输出目录”
string imagePath = "ms-appx:///Assets/LOGO.png";
BitmapImage bitmapImage = new BitmapImage(new Uri(imagePath));
MyPicture.Source = bitmapImage;