ソース掲示板




すべてから検索

キーワード   条件 表示 現行ログ 過去ログ トピックス 名前 本文
Windows8(C#) ストアアプリ : 複数画面を同時にメモリ上に置く画面間移動処理
日時: 2013/06/10 20:33
名前: lightbox



App.xaml.cs
拡張子:
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using Windows.ApplicationModel;
using Windows.ApplicationModel.Activation;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

//名前空間
namespace LBOX_TwitterListView1
{
	//クラス
	sealed partial class App : Application
	{
		// 簡単に参照可能なように、static で定義
		public static ListMain listMain = null;
		public static MainPage mainPage = null;
		public static NextPage nextPage = null;
		// ルートフレームの作成
		public static Frame rootFrame = Window.Current.Content as Frame;

		//コンストラクタ
		public App()
		{
			this.InitializeComponent();
			this.Suspending += OnSuspending;
		}

		// *************************************************
		// アプリケーションがエンド ユーザーによって正常に起動されたときに呼び出されます
		// *************************************************
		protected override void OnLaunched(LaunchActivatedEventArgs args)
		{

			// ウィンドウに既にコンテンツが表示されている場合は、アプリケーションの初期化を繰り返さずに、
			// ウィンドウがアクティブであることだけを確認してください
			if (rootFrame == null)
			{

				Debug.WriteLine("ルートフレームを新しく作成しました");
				rootFrame = new Frame();

				if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
				{
					//TODO: 以前中断したアプリケーションから状態を読み込みます。
				}

				// フレームを現在のウィンドウに配置します
				Window.Current.Content = rootFrame;
			}

			if (rootFrame.Content == null)
			{

				// *************************************************
				// ナビゲーション スタックが復元されていない場合、最初のページに移動します。
				// このとき、必要な情報をナビゲーション パラメーターとして渡して、新しいページを
				// 構成します
				// *************************************************
				if (!rootFrame.Navigate(typeof(MainPage)))
				{
					throw new Exception("Failed to create initial page");
				}

				Debug.WriteLine("ルートフレームにページをロードしました");

			}

			// 現在のウィンドウがアクティブにします
			Window.Current.Activate();
		}

		// *************************************************
		// アプリケーションの実行が中断されたときに呼び出されます。
		// *************************************************
		private void OnSuspending(object sender, SuspendingEventArgs e)
		{
			Debug.WriteLine("アプリケーションの実行が中断されました");

			var deferral = e.SuspendingOperation.GetDeferral();
			//TODO: アプリケーションの状態を保存してバックグラウンドの動作があれば停止します
			deferral.Complete();
		}
	}
}
メンテナンス

MainPage から NextPage に移動する処理 ( No.1 )
日時: 2013/06/10 20:27
名前: lightbox


日時: 2013/06/10 20:27
名前: lightbox
MainPage.xaml.cs
拡張子:
// *************************************************
// 次ページ
// *************************************************
private void NextpageButton_Click(object sender, RoutedEventArgs e)
{
	// 最初の次ページへの移動
	if (App.nextPage == null)
	{
		App.rootFrame.Navigate(typeof(NextPage));
	}
	// 2回目以降の次ページへの移動
	else
	{
		App.rootFrame.Content = App.nextPage;
	}
}
このアーティクルの参照用URLをクリップボードにコピー メンテナンス
NextPage での処理 ( No.2 )
日時: 2013/06/10 20:30
名前: lightbox
コンストラクタ
拡張子:
public NextPage()
{
	this.InitializeComponent();
	// このページの保存
	App.nextPage = this;
}
戻る処理
拡張子:
App.rootFrame.Content = App.mainPage;
このアーティクルの参照用URLをクリップボードにコピー メンテナンス
MainPage の コンストラクタ ( No.3 )
日時: 2013/06/10 20:33
名前: lightbox
MainPage.xaml.cs
拡張子:
App.mainPage = this;
このアーティクルの参照用URLをクリップボードにコピー メンテナンス