[英]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"/>
這里Image Source="Assets/User.png"
檢查您的Assets folder
是否存在User.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"/>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.