简体   繁体   English

图像不显示在 WinUI3 XAML 中

[英]Image does not display in WinUI3 XAML

I am trying to add a picture to my Window in WinUI3 and the image is never rendered.我正在尝试在 WinUI3 中将图片添加到我的窗口中,并且永远不会渲染图像。 When checking in the live visual tree, the actual size of the image is 0 even though its width and height are set to 200px.检查实时可视化树时,图像的实际大小为 0,即使其宽度和高度设置为 200 像素。 Can someone tell me what's wrong with my XAML ?有人可以告诉我我的 XAML 有什么问题吗?

<Window
    x:Class="ClientWinUI.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:ClientWinUI"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    >
    
    <Grid Background="#FF494A51">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="1*" />
            <ColumnDefinition Width="2*" />
            <ColumnDefinition Width="2*" />
            <ColumnDefinition Width="1*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="1*" />
            <RowDefinition Height="2*" />
            <RowDefinition Height="1*" />
        </Grid.RowDefinitions>
        <Image Stretch="Fill"  Width="200" Height="200" Source="Images/logo.png"/>
    </Grid>
</Window>

Found the bug.发现了错误。 I was debugging the package itself and I needed to add the image to the assets found in the package.我正在调试包本身,我需要将图像添加到包中的资产中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM