以下是我的代碼。單擊按鈕時,我無法從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);
}
}
感謝您的答覆..你知道我有代碼,但隨後評論它..科斯總是有錯誤說InitializeComponent()在當前上下文中找不到 – Shaireen 2010-12-20 10:39:23