Windows Phone 8 Silverlight 不在第二页加载新图像

Windows Phone 8 Silverlight dont load new images on second page

我正在开发 windows phone 8.1 silverlight 应用。

我有这个问题:

尝试使用打开新页面时:

NavigationService.Navigate(new Uri("/Views/Menu.xaml", UriKind.Relative));

页面正常打开,但是我无法加载新图片,我只能使用我在first page上使用过的图片。

首页XAML:

<Grid x:Name="LayoutRoot" Background="#f3f3f4">

    <!--TitlePanel contains the name of the application and page title-->
    <StackPanel x:Name="LogoPanel" Grid.Row="0" Margin="12,120,0,28">
        <Image Height="100" Source="Assets/Logo.png"/>
    </StackPanel>

    <StackPanel x:Name="LogoPanel1" Grid.Row="0" Margin="12,400,0,28">
        <TextBox x:Name="txtUsername" Height="72" TextWrapping="Wrap" TextAlignment="Center" Text="Username" Foreground="#A7A5A8" GotFocus="TextBox_GotFocus" LostFocus="txtUsername_LostFocus"/>
        <PasswordBox x:Name="txtPassword" Height="72" Password="password"   HorizontalAlignment="Center" Foreground="#A7A5A8" Width="468" Style="{StaticResource PasswordBoxStyle1}" LostFocus="txtPassword_LostFocus" GotFocus="txtPassword_GotFocus"/>
        <Button Content="LOGIN" Background="#18a689" Click="Button_Click"/>
    </StackPanel>
</Grid>

第二页XAML:

<Grid x:Name="LayoutRoot" Background="#f3f3f4">
    <Grid.RowDefinitions>
        <RowDefinition Height="200" />
    </Grid.RowDefinitions>
    <!--TitlePanel contains the name of the application and page title-->
    <StackPanel x:Name="userPanel" Height="200" Grid.Row="0" Margin="0,0,0,0" Background="#18a689">
        <Grid x:Name="userGrid">
            <Grid.RowDefinitions>
                <RowDefinition Height="200" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>

            <!-- User Image -->
            <Image Grid.Row="0" Grid.Column="0" Height="178" Source="Assets/User.png"/>

            <!-- User Info -->
            <TextBlock Grid.Column="1" HorizontalAlignment="Left" Margin="0,60,0,0" TextWrapping="Wrap" Text="Ricardo Sampaio" VerticalAlignment="Top" FontSize="24" FontWeight="Bold"/>
            <TextBlock Grid.Column="1" HorizontalAlignment="Left" Margin="0,100,0,0" TextWrapping="Wrap" Text="rsampaio@hydra.pt" VerticalAlignment="Top" FontSize="24"/>
        </Grid>
    </StackPanel>

    <!--ContentPanel - place additional content here-->
    <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
    </Grid>
</Grid>

CS 文件:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using FlyGolf_V1.Resources;
using System.Windows.Media;

namespace FlyGolf_V1
{
    public partial class MainPage : PhoneApplicationPage
    {
    // Constructor
    public MainPage()
    {
        InitializeComponent();
    }

    #region placeholders

    private void TextBox_GotFocus(object sender, RoutedEventArgs e)
    {
        if (txtUsername.Text == "Username")
        {
            txtUsername.Text = "";
        }
    }

    private void txtUsername_LostFocus(object sender, RoutedEventArgs e)
    {
        if (txtUsername.Text == "")
        {
            txtUsername.Text = "Username";
        }
    }

    private void txtPassword_GotFocus(object sender, RoutedEventArgs e)
    {
        if (txtPassword.Password == "password")
        {
            txtPassword.Password = "";
        }
    }

    private void txtPassword_LostFocus(object sender, RoutedEventArgs e)
    {
        if (txtPassword.Password == "")
        {
            txtPassword.Password = "password";
        }
    }

    #endregion

    private void Button_Click(object sender, RoutedEventArgs e)
    {
        NavigationService.Navigate(new Uri("/Views/Menu.xaml", UriKind.Relative));
    }
  }
}

有人可以帮助我吗?

首页XAML:

<Image Height="100" Source="Assets/Logo.png"/>

这里是图片Source="Assets/Logo.png"

第二页XAML:

<Image Grid.Row="0" Grid.Column="0" Height="178" Source="Assets/User.png"/>

这里是图片Source="Assets/User.png"

检查您的 Assets folderUser.png 个图像出口。

第二页XAML编辑:

<Image Grid.Row="0" Grid.Column="0" Height="178" Source="/Assets/User.png"/>

您好,请在您的 XAML 文件

中的 Assets/User.png 之前添加 /(斜杠)

如下..

<Image Grid.Row="0" Grid.Column="0" Height="178" Source="/Assets/User.png"/>