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