【发布时间】:2010-12-20 04:45:09
【问题描述】:
以下是我的代码。我无法通过单击按钮从 MasterPage.xaml 导航到 Slide_show.xaml。
public partial class MainPage : PhoneApplicationPage
{ public MainPage()
{
InitializeComponent();
Loaded += new RoutedEventHandler(MainPage_Loaded);
}
private void Play_C(object sender, RoutedEventArgs e)
{
//Slide_show obj=new Slide_show();
//obj.MainPage_Loaded(sender,e);
try
{
this.NavigationService.Navigate(new Uri("Slide_show.xaml",UriKind.Relative));
}
catch (Exception e1)
{
MessageBox.Show("unable to show");
}
}
xaml 文件是
<phone:PhoneApplicationPage xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
x:Class="photoViewer.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="PortraitOrLandscape" Orientation="Portrait"
shell:SystemTray.IsVisible="True">
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Button Content="Play" Grid.Row="1" Height="72" HorizontalAlignment="Right" Margin="0,696,170,0" Name="button5" VerticalAlignment="Top" Width="114" Background="Transparent" Click="Play_C"/>
</Grid>
Slide_show.xaml.cs 文件是
public class Slide_show : PhoneApplicationPage
{
public Slide_show()
{
//InitializeComponent();
Loaded += new RoutedEventHandler(MainPage_Loaded);
}
}
【问题讨论】:
标签: c# silverlight visual-studio-2010 xaml windows-phone-7