2016-10-10 8 views
0

Я пытаюсь сделать игру памяти, код, приведенный ниже:я не вижу изображение, я добавляю - UWP

<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> 

Однако, когда я добавить изображение, я не может этого видеть. Я создал изображение, как показано ниже:

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

Ничто не показывает, картина существует и я перетащил его из активов, что я должен сделать, чтобы быть в состоянии увидеть картину? Должен ли я помещать изображение и текстовый блок или кнопку на одной панели?

+0

ли у вас есть посмотрите примеры на странице [Image.Source] (https://msdn.microsoft.com/library/windows/apps/xaml/windows.ui.xaml.controls.image.source.aspx)? –

ответ

0

Попробуйте это:

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

Изображение должно добавлено в Visual Studio в каталоге активов. Если это не так:

  1. правой кнопкой мыши на каталоге ресурсов в Visual Studio
  2. Добавить
  3. Exists Элемент
  4. Выберите изображение

It works for me

Смежные вопросы