简体   繁体   English

我看不到要添加的图像-UWP

[英]I don't see the image I'm adding - UWP

I'm trying to make a memory game, code shown below: 我正在尝试制作一个记忆游戏,代码如下所示:

<Page
x:Class="MemoGame.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:MemoGame"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="1*"/>
        <ColumnDefinition Width="1*"/>
        <ColumnDefinition Width="1*"/>
        <ColumnDefinition Width="1*"/>
    </Grid.ColumnDefinitions>

    <Grid.RowDefinitions>
        <RowDefinition Height="1*"/>
        <RowDefinition Height="2*"/>
        <RowDefinition Height="2*"/>
        <RowDefinition Height="2*"/>
        <RowDefinition Height="2*"/>
    </Grid.RowDefinitions>


    <TextBlock Grid.Row="0" Grid.ColumnSpan="4" FontSize="24" FontStyle="Italic">Memo game by Ido and Jacob</TextBlock>

    <Rectangle x:Name="R1C1" Grid.Row="1" Grid.Column="0" Fill="Gray" StrokeThickness="2" Margin="4" Stroke="Black"></Rectangle>
    <Rectangle x:Name="R1C2" Grid.Row="1" Grid.Column="1" Fill="Gray" StrokeThickness="2" Margin="4" Stroke="Black"></Rectangle>
    <Rectangle x:Name="R1C3" Grid.Row="1" Grid.Column="2" Fill="Gray" StrokeThickness="2" Margin="4" Stroke="Black"></Rectangle>
    <Rectangle x:Name="R1C4" Grid.Row="1" Grid.Column="3" Fill="Gray" StrokeThickness="2" Margin="4" Stroke="Black"></Rectangle>

    <Rectangle x:Name="R2C1" Grid.Row="2" Grid.Column="0" Fill="Gray" StrokeThickness="2" Margin="4" Stroke="Black"></Rectangle>
    <Rectangle x:Name="R2C2" Grid.Row="2" Grid.Column="1" Fill="Gray" StrokeThickness="2" Margin="4" Stroke="Black"></Rectangle>
    <Rectangle x:Name="R2C3" Grid.Row="2" Grid.Column="2" Fill="Gray" StrokeThickness="2" Margin="4" Stroke="Black"></Rectangle>
    <Rectangle x:Name="R2C4" Grid.Row="2" Grid.Column="3" Fill="Gray" StrokeThickness="2" Margin="4" Stroke="Black"></Rectangle>

    <Rectangle x:Name="R3C1" Grid.Row="3" Grid.Column="0" Fill="Gray" StrokeThickness="2" Margin="4" Stroke="Black"></Rectangle>
    <Rectangle x:Name="R3C2" Grid.Row="3" Grid.Column="1" Fill="Gray" StrokeThickness="2" Margin="4" Stroke="Black"></Rectangle>
    <Rectangle x:Name="R3C3" Grid.Row="3" Grid.Column="2" Fill="Gray" StrokeThickness="2" Margin="4" Stroke="Black"></Rectangle>
    <Rectangle x:Name="R3C4" Grid.Row="3" Grid.Column="3" Fill="Gray" StrokeThickness="2" Margin="4" Stroke="Black"></Rectangle>

    <Rectangle x:Name="R4C1" Grid.Row="4" Grid.Column="0" Fill="Gray" StrokeThickness="2" Margin="4" Stroke="Black"></Rectangle>
    <Rectangle x:Name="R4C2" Grid.Row="4" Grid.Column="1" Fill="Gray" StrokeThickness="2" Margin="4" Stroke="Black"></Rectangle>
    <Rectangle x:Name="R4C3" Grid.Row="4" Grid.Column="2" Fill="Gray" StrokeThickness="2" Margin="4" Stroke="Black"></Rectangle>
    <Rectangle x:Name="R4C4" Grid.Row="4" Grid.Column="3" Fill="Gray" StrokeThickness="2" Margin="4" Stroke="Black"></Rectangle>
</Grid>

However, when I add an image, I can't see it. 但是,添加图像时看不到它。 I set up the image as below: 我将图像设置如下:

        <Image Source="c:\users\prinsnal\documents\visual studio 2015\Projects\MemoGame\MemoGame\Assets\I3LeJ3H.png" Grid.Row="0" Grid.Column="0"></Image>

Nothing is showing, the picture exists and I dragged it from the assets, what should I do to be able to see the picture? 什么都没显示,图片存在并且我将其从资产中拖动了,我应该怎么做才能看到图片? Should I place a picture and a textblock or a button on the same panel? 我应该在同一面板上放置图片和文本块或按钮吗?

Try this: 尝试这个:

<Image Source="Assets\I3LeJ3H.png" Grid.Row="0" Grid.Column="0"></Image>

The image must added in Visual Studio in the Assets directory. 该图像必须在Visual Studio的Assets目录中添加。 If it isn't: 如果不是:

  1. Right click on the Assets directory in Visual Studio 右键单击Visual Studio中的Assets目录
  2. Add
  3. Exists Element 存在元素
  4. Select your image 选择你的图片

这个对我有用

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

相关问题 为什么在WPF中看不到以编程方式生成的图像? - Why don't I see my programmatically generated image in WPF? Unity 要求一个 } 但我不明白为什么 - Unity is asking for a } but I don't see why 我正在努力使单声道android简单的“你好世界”,但我没有在模拟器中看到“你好世界”为什么? - I'm trying to make mono android simple “hello world” but I don't see “hello world” in the emulator why? 我不认为我要修改此收藏集 - I don't think I'm modifying this collection 我不明白我得到的NewNotImplementedException运行时错误 - I don't understand the NewNotImplementedException runtime error I'm getting SqlParameter已经包含在另一个SqlParameterCollection中,但是我没有看到 - SqlParameter is already contained by another SqlParameterCollection, but I don't see how 我的RSS中没有看到任何图片 - I don't see any pictures in my RSS 为什么我在客户端上看不到响应 class 的属性? - Why I don't see properties of the response class on the client? 语言设置为“默认”但我没有看到resource.dll? - Language set to “Default” but i don't see a resource.dll? 我在DLLImport中使用的引用中没有看到Dll - I don't see the Dll in references which is used in DLLImport
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM