内容へ移動
ユーザ用ツール
サイト用ツール
検索
ツール
文書の表示
以前のリビジョン
バックリンク
最近の変更
メディアマネージャー
サイトマップ
ログイン
>
現在位置:
home
»
wiki
»
Windows Phone
»
7.1
»
Tips
»
019 ページの遷移
トレース:
wiki:windowsphone:7.1:tips:019
この文書は読取専用です。文書のソースを閲覧することは可能ですが、変更はできません。もし変更したい場合は管理者に連絡してください。
====== 019 ページの遷移 ====== ===== 概要 ===== 画面の切り替えを行います。サンプルではレイアウトも記述しているためソースが長めになっていますが、必要なものはページを切り替える「NavigationService.Navigate」と、切り替え先で呼び出されるOnNavigatedToメソッドのみです。また、ページを切り替える直前で呼ばれるメソッドは OnNavigatedFromになっています。 ==== MainPage.xaml ==== <code xml> <phone:PhoneApplicationPage x:Class="BaseApp.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="Portrait" Orientation="Portrait" shell:SystemTray.IsVisible="True"> <!--LayoutRoot is the root grid where all page content is placed--> <Canvas x:Name="LayoutRoot" Background="Black"> <Button Canvas.Left="116" Canvas.Top="121" Content="サブページへ" Height="130" Name="button1" Width="300" Click="ChangePage_Click" /> </Canvas> </phone:PhoneApplicationPage> </code> ==== MainPage.xaml.cs ==== <code csharp> using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Media.Imaging; using System.Windows.Shapes; using Microsoft.Phone.Controls; namespace BaseApp { // エントリーポイント public partial class MainPage : PhoneApplicationPage { // コンストラクタ public MainPage() { // コンポーネントの初期化。 InitializeComponent(); } // ページ遷移開始時に呼ばれるメソッド。 protected override void OnNavigatedFrom(System.Windows.Navigation.NavigationEventArgs e) { System.Diagnostics.Debug.WriteLine("call OnNavigatedFrom"); } // 「サブページへ」がクリックされた。 private void ChangePage_Click(object sender, RoutedEventArgs e) { this.NavigationService.Navigate(new Uri("/SubPage.xaml", UriKind.Relative)); } } } </code> ==== SubPage.xaml ==== <code xml> <phone:PhoneApplicationPage x:Class="BaseApp.SubPage" 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="Portrait" Orientation="Portrait" shell:SystemTray.IsVisible="True"> <!--LayoutRoot is the root grid where all page content is placed--> <Canvas x:Name="LayoutRoot" Background="Black"></Canvas> </phone:PhoneApplicationPage> </code> ==== SubPage.xaml.cs ==== <code csharp> using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Media.Imaging; using System.Windows.Shapes; using Microsoft.Phone.Controls; namespace BaseApp { // エントリーポイント public partial class SubPage : PhoneApplicationPage { // コンストラクタ public SubPage() { } // NavigationService.Navigate後に呼ばれるメソッド。 protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { System.Diagnostics.Debug.WriteLine("call OnNavigatedTo"); } } </code>
Permalink
wiki/windowsphone/7.1/tips/019.txt
· 最終更新: 2014/11/09 12:56 (外部編集)
ページ用ツール
ログイン
文書の表示
文書の先頭へ
印刷
以前のリビジョン
バックリンク
最近の変更
メディアマネージャー
サイトマップ
oeffentlich