SlideShare a Scribd company logo
Windows ストア lob アプリ開発のためのガイダンスとフレームワークのご紹介 rev
テクニカルエバンジェリスト
http://blogs.msdn.com/b/shosuz
MTC アーキテクト
http://www.microsoft.com/ja-jp/business/mtc/ads.aspx
呟きネタは主に、Windows Azure, Windows, RIA,
HTML5, MVVM, iOS/Android x Windows Azure
連携, Guitar … 等
ASPIC 執行役員 (‘05 ~),
Wipse モバイル x クラウド部会長(’11 ~)
東京工業大学大学院(’13~),早稲田大学大学院
(’05-12),中央大学総合政策学部(’08-10)で
非常勤講師
Microsoft 軽音楽部 広報担当 (Gt./Key./DAW)
(‘12 ~)
https://www.facebook.com/shosuz
Windows ストア lob アプリ開発のためのガイダンスとフレームワークのご紹介 rev
Windows ストア LOB アプリ開発
ストアアプリの企業導入に伴う課題
既存アプリケーション
との住み分け
アプリケーション化
のターゲット
開発リソース確保、
技術研修
配布の方法
百貨店の店舗用商品カタログのフロー例
SharePoint Site
http://sharepoint/url
se
ar
ch
Browse PageSite Actions username
Parent > Parent > Current Page
Page Title
This Site: site search
Libraries
Site Pages
Shared
Documents
Drop Off
Library
Custom
library
Current PagePage One Page Two
7:37 AM
マスター
情報を取得
商品情報
を検索
マスター情報を検索
画像 URL
を検索
画像 URL
を取得
画像 URLを
含む商品情
報を取得
画像情報を
リクエスト
画像情報を
返す
XML-RPC
REST
REST
Microsoft Architect Forum 2013
データソースとしての選択肢の選定
データベース
との接続
(特に SQL
Server)
社内の
コンテンツ
サーバー
クラウド上の
コンテンツ
サーバー
クラウドや
公開された
サービスとの
連携
WCF Data
Services
SharePoint
Server
2010/2013
Office 365
ASP.NET
Web API、
Mobile
Services
Microsoft Architect Forum 2013
ストアアプリ Grid テンプレートや
MVVM (Model-View-ViewModel) の利用
 階層型ページ遷移
で画面を活用
 ユーザーに適切な
情報を提供
 画面に必要な
コンテンツのみ
表示
 MVVM の積極的
採用
MVVM (Model-View-
ViewModel)サンプル実装
Contoso Travel
Featured destinations Last minute deals
7 night Alaska Cruise
Last Minute Deals
Featured destinationsBarcelona,Spain
Last Minute Deals7 Night Alaska Cruise
Ocean View Cabins
Upgrade from an inside cabin and
save $43/night/person!
Picture windows with ocean and port
views
From $2,099 — only
$150/night/person based on double
occupancy
Suites
Upgrade from an inside cabin
and save $43/night/person!
Picture windows with ocean
and port view
From $2,099 — only
$150/night/person do
My Trips Weather
7 days
Chicago (3/11 – 3/19)
Today
54/43
Mostly Sunny
Today
54/43
Mostly Sunny
Today
54/43
Mostly Sunny
Today
54/43
Mostly Sunny
Today
54/43
Mostly Sunny
Attractions
My TripsFeatured Destinations
Top Destinations for 2012
Barcelona, Spain
My Trips City GuideCity Guide
Windows ストアアプリ
Grid テンプレート
MVVM フレームワークのご紹介
•
•
• MVC
• Presentation
Model pattern
• XAML
デザイナー担当 開発者が担当
View
ViewModel
Model
UI、XAML
ロジック、状態
データソース
Data Model
View
XAML
分離コード
View Model
State +
Operations
Change
Notification
Data-binding
and commands
独自の
“MVVM” モデル
BindableBase
Data Model
View
XAML
分離コード
View Model
State +
Operations
Change
Notification
Data-binding
and commands
実装済みサンプルご紹介
- Adventure Works
Reference Implementation
http://prismwindowsruntime.codeplex.com/
Windows ストア lob アプリ開発のためのガイダンスとフレームワークのご紹介 rev
Windows ストア lob アプリ開発のためのガイダンスとフレームワークのご紹介 rev
Demo
Windows Store Business Apps
Guidance using Prism for
Windows Runtime
http://prismwindowsruntime.codeplex.com
ビジネスアプリケーションと
Prism
- patterns & practices guidance for building
Windows Store business apps -
Windows ストア lob アプリ開発のためのガイダンスとフレームワークのご紹介 rev
Windows ストア lob アプリ開発のためのガイダンスとフレームワークのご紹介 rev
Windows ストア lob アプリ開発のためのガイダンスとフレームワークのご紹介 rev
// View フォルダを作りStartPage.xaml を追加
// その中に追加する
<TextBlock
Text="Hello World!!!"
Style="{StaticResource HeaderTextStyle}" />
// App.xaml.cs の using の部分より下を全部消した後、追加
// Microsoft.Practices.Prism.StoreApps ライブラリ参照設定
using Microsoft.Practices.Prism.StoreApps;
sealed partial class App : MvvmAppBase
{
public App()
{
this.InitializeComponent();
}
}
// App.xaml を下記のように囲む
<Infrastructure:MvvmAppBase
xmlns:Infrastructure=
"using:Microsoft.Practices.Prism.StoreApps"
>
...
</Infrastructure:MvvmAppBase>
protected override void OnLaunchApplication
(LaunchActivatedEventArgs args)
{
NavigationService.Navigate("Start", null);
}
MVVM (Model-View-ViewModel)
の基本的な実装
- patterns & practices guidance for building
Windows Store business apps -
Windows ストア lob アプリ開発のためのガイダンスとフレームワークのご紹介 rev
// StartPageViewModel クラスに FirstName プロパティと背後の
フィールドを追加
private string _firstName;
public string FirstName
{
get { return _firstName; }
set { _firstName = value; }
}
// Microsoft.Practices.Prism.StoreApps ライブラリのタイプを
StartPageViewModel クラスにインポート
// ViewModel Base クラスから StartPageViewModel クラスを作成
することにより、ViewModel Base クラスの
INotifyPropertyChanged の実装を利用することが可能
using Microsoft.Practices.Prism.StoreApps;
// Microsoft.Practices.Prism.StoreApps ライブラリを利用し、
FirstName プロパティを SetProperty メソッドを使うように変更
public string FirstName
{
get { return _firstName; }
set { SetProperty(ref _firstName, value); }
}
// ViewModelLocator.AutoWireViewModel attached property を
StartPage のための Page コントロールに追加する
<Page xmlns:Infrastructure=
"using:Microsoft.Practices.Prism.StoreApps"
Infrastructure:ViewModelLocator.AutoWireViewModel
="True"
... >
...
</Page>
// StartPageViewModel クラスを更新し、FirstName プロパティに
[RestorableState] アトリビュートを適用
[RestorableState]
public string FirstName
{
get { return _firstName; }
set { SetProperty(ref _firstName, value); }
}
Flyout Services クラスを使った
Flyout の作成・表示
- patterns & practices guidance for building
Windows Store business apps -
Windows ストア lob アプリ開発のためのガイダンスとフレームワークのご紹介 rev
// SignInFlyout ページを作成
// その中の Grid 内に TextBlock 追加
<Grid Background="White">
<TextBlock Text="Sign In!"
Foreground="Black" />
</Grid>
// Microsoft.Practices.Prism.StoreApps ライブラリ
内で StandardFlyoutSize クラスを定義
// FlyoutView base クラスから SignInFlyout クラスを継承するよう
変更。また、コンストラクターの中で Width も決定
public sealed partial class SignInFlyout : FlyoutView
{
public SignInFlyout() : base(StandardFlyoutSize.Narrow)
{
this.InitializeComponent();
}
}
// SignInFlyout.xaml ファイルを更新し、SignInFlyout View が
Microsoft.Practices.Prism.StoreApps ライブラリにある
FlyoutView base class を拡張するように変更する
<Infrastructure:FlyoutView
xmlns:Infrastructure=
"using:Microsoft.Practices.Prism.StoreApps"
...
</Infrastructure:FlyoutView>
// StartPage が SignInFlyout を表示するように変更する
Microsoft.Practices.Prism.StoreApps 名前空間からの
インターフェースを StartPageViewModel クラスにインポートする
using Microsoft.Practices.Prism.StoreApps.Interfaces
// StartPageViewModel クラスにコンストラクタを追加し、
IFlyoutService タイプのパラメータを取るようにする
StartPageViewModel クラスにはデフォルトコンストラクタは存在しない
public StartPageViewModel(IFlyoutService flyoutService)
{
}
// ViewModelLocator をファクトリーに提供し StartPage のための
ViewModel インスタンスを作成
// App class 内にある OnInitialize メソッドをオーバーライドし
ViewModelLocator に StartPageViewModel インスタンス構成を教える
protected override void
OnInitialize(IActivatedEventArgs args)
{
ViewModelLocator.Register(typeof(StartPage).ToString(),
() => new StartPageViewModel(FlyoutService));
}
// StartPage 内の StackPanel に SignInFlyout を表示するボタンを追加
当該ボタンの Command property は StartPageViewModel クラス内の
SignInCommand にバインドされる
<StackPanel>
<TextBlock Text="Hello World!!!" />
<TextBox Text=
"{Binding FirstName, Mode=TwoWay}" />
<Button Content="ShowFlyout"
Command="{Binding SignInCommand}" />
</StackPanel>
// StartPageViewModel class に System.Windows.Input 名前空間をインポート
using System.Windows.Input;
// SignInCommand プロパティを StartPageViewModel クラスに追加
Public Icommand SignInCommand { get; private set; }
// 当該プロパティは private setter を持つ(内部的にのみセット可能故)
// SignInCommand プロパティを DelegateCommand インスタンスに設定しFlyoutServiceを呼び出す
public StartPageViewModel(IFlyoutService flyoutService)
{
SignInCommand = new DelegateCommand(() =>
flyoutService.ShowFlyout("SignIn"));
}
// 設定ペインに SignInFlyout を表示するアイテムを追加する
// アプリを停止し、App class の中の GetSettingsCharmActionItems メソッドをオーバーライド
// このメソッドは SettingsPane class の CommandsRequested イベント が発生したとき呼ばれる
// SignInFlyout を開くための設定ペインに SettingsCharmActionItem を追加する
Protected override Ilist<SettingsCharmActionItem>
GetSettingsCharmActionItems()
{
return new List<SettingsCharmActionItem>{ new
SettingsCharmActionItem("Sign In",
() => FlyoutService.ShowFlyout("SignIn"))};
}
Dependency Injection コンテナ
の統合
- patterns & practices guidance for building
Windows Store business apps -
Windows ストア lob アプリ開発のためのガイダンスとフレームワークのご紹介 rev
// Dependency Injection Container ライブラリへの参照を追加
※ Unity v3 container via NuGet
(http://www.nuget.org/packages/Unity/).
// App class に当該コンテナを保持するプライベートメンバー変数追加
private UnityContainer _container =
new UnityContainer();
// App class 内の Resolve メソッドをオーバーライドして
当該コンテナが一つのタイプからオブジェクトインスタンスを
生成できるようにする
protected override object Resolve(Type type)
{
return _container.Resolve(type);
}
Windows ストア lob アプリ開発のためのガイダンスとフレームワークのご紹介 rev
// MvvmAppBase により提供される3つのサービスを登録するコード
protected override void OnInitialize
(IActivatedEventArgs args)
{
_container.RegisterInstance(NavigationService);
_container.RegisterInstance(FlyoutService);
_container.RegisterInstance(SessionStateService);
}
ユーザー入力のバリデーション
- patterns & practices guidance for building
Windows Store business apps -
HighlightFormFieldOnErrors.PropertyErrors
private string _username;
private string _password;
public string Username
{
get { return _username; }
set { SetProperty(ref _username, value); }
}
public string Password
{
get { return _password; }
set { SetProperty(ref _password, value); }
}
// 各プロパティに “Required”・“StringLength” DataAnnotations
attributes を追加
[Required]
[StringLength(10)]
public string Username
{
get { return _username; }
set { SetProperty(ref _username, value); }
}
[Required]
[StringLength(20)]
public string Password ・・・
// Model クラスができたのでそれを SignInFlyoutViewModel 上で公開
// ViewModels フォルダに SignInFlyoutViewModel 追加
// SignInFlyoutViewModel に当該 Credential Model を公開する
プロパティを追加
public class SignInFlyoutViewModel
{
public SignInFlyoutViewModel()
{
UserCredential = new Credential();
}
public Credential UserCredential { get; set; }
}
// SignInFlyout ページ とこのページ (view) とを
SignInFlyoutViewModel にバインド
ViewModelLocator.AutoWireViewModel=”True”
// いくつか Controls を View に追加して、当該 ViewModel の
Credential Username プロパティと Password プロパティ値を格納
//何らかの Validation error messagesとバインドされた TextBlock群
<TextBox Text=
"{Binding UserCredential.Username, Mode=TwoWay}"
BorderBrush="Black" />
<TextBlock Text="{Binding UserCredential.Errors[Username],
Converter={StaticResource
FirstErrorConverter}}" Foreground="Red" />
<TextBox Text="{Binding UserCredential.Password,
Mode=TwoWay}" BorderBrush="Black" />
<TextBlock Text="{Binding UserCredential.Errors[Password],
Converter={StaticResource
FirstErrorConverter}}" Foreground="Red"/>
Windows ストア lob アプリ開発のためのガイダンスとフレームワークのご紹介 rev
// FirstErrorConverter のソース
public sealed class FirstErrorConverter : IValueConverter
{
public object Convert(object value, Type targetType,
object parameter, string language)
{
ICollection<string> errors = value as ICollection<string>;
return errors != null && errors.Count > 0 ?
errors.ElementAt(0):null;
}
public object ConvertBack(object value, Type targetType,
object parameter, string language)
{
throw new NotImplementedException();
}
}
// この値コンバータを Static resource として使うには、
App.xaml の中で参照設定する
<ResourceDictionary>
...
<converters:FirstErrorConverter
x:Key="FirstErrorConverter" />
</ResourceDictionary>
// Model プロジェクトの全てのプロパティをバリデートする
UserCredential.ValidateProperties()
public SignInFlyoutViewModel()
{
UserCredential = new Credential();
ValidateAll =
new DelegateCommand(() =>
UserCredential.ValidateProperties());
}
public Credential UserCredential { get; set; }
public ICommand ValidateAll { get; set; }
// View にボタンを追加して ValidateAll command にバインド
<Button Command="{Binding ValidateAll}"
Content="Validate All"
Foreground="Black"/>
public class MyViewModel : ViewModel, INavigationAware
{
private string _name;
[RestorableState]
public string Name
{
get { return _name; }
set { SetProperty(ref _name, value); }
}
}
Model の追加(1)
Entity Framework + Code First によるデータモデル構築
Entity Data Model概念モデル (CSDL)
問題領域の概念的な
エンティティやリレーションの定義
マッピング (MSL)
両モデル間の対応付け
ストレージモデル (SSDL)
特定のデータソースに基づく
論理スキーマのモデル
プログラム上の
オブジェクト
Entity SQL
概念モデルのエンティティと
オブジェクトとの間でマッピング
プレゼンテーション層
ドメイン層
データ層
public partial class Entry
{
public virtual int ID
{
get;
set;
}
RDB
Model の追加(2)
ASP.NET MVC4 Web API によるサービスの公開と利用
•
クライアント
アプリ
Web サーバー
ASP.NET
Web
API
Get/Post/
Put/Delete
JSON/XML
データソース
ブラウザー
Entity
Framework
サービス
• await
XAML / C# ASP.NET
Web APIJSON
Get/Post/
Put/Delete
var client = new HttpClient();
HttpResponseMessage response =
await client.GetAsync(“サービスのURI");
var result =
await
response.Content.ReadAsStringAsync();
var pictures = JsonArray.Parse(result);
// JSONの結果をオブジェクトにバインド …
Windows Azure 連携シナリオ
• オンライン楽器ストアアプリ
各商品を表示 タイトルを編集 詳細情報編集、削除可能
スタートスクリーン 全商品表示(Hub) 一覧・登録(Sections)
個別商品表示・編集(Details)
アーキテクチャー概要
Windows ストアアプリ
・店舗管理者用 - 編集・登録
・一般ユーザー用 - 閲覧・購入・
プッシュ通知(Mobile Services)・
メール(SendGrid)
69
Entity
Framework
SQL Database
Windows Azure
Web サイト
Windows Azure
Windows Azure
Websites
Windows Azure
SQL Database
Windows Azure
Storage (BLOB)
画像
文字
数値
ASP.NET Web API
Entity
Framework
ドメイン
モデル
店舗
管理者
一般
ユーザー
Grid
テンプレート
Get/Post/
Put/Delete
JSON
REST
CodeFirst
サイド
ローディング
Windows
ストア
Demo
Musical Instruments Store
utilizing Adventure Works RI
working with Windows Azure
as Model
http://aka.ms/VS2012-Case
http://aka.ms/VS2012-Sol
http://aka.ms/VS2012-Prod
http://aka.ms/VS2012-Try
http://aka.ms/VS2012-Lic
http://prismwindowsruntime.codeplex.com
.exe
.zip
Windows ストア lob アプリ開発のためのガイダンスとフレームワークのご紹介 rev

More Related Content

PDF
ASP.NET MVC 2 ~新機能の紹介~
PDF
jQuery と MVC で実践する標準志向 Web 開発
PPTX
コーディング不要! Entity Framework 6.1.3 + ASP.NET MVC 5 サンプル アプリケーション構築 手順書
PPTX
20200304 vuejs
PDF
Workspace ONE テクニカルガイド MDM
PPTX
Building Silverlight Large Scale Application Using MVVM
PDF
Workspace one テクニカルガイド mcm
PPTX
モバイルアプリケーション開発体験ハンズオン ~実装からビルド・テスト・ベータテスト配布まで~ Android 編
ASP.NET MVC 2 ~新機能の紹介~
jQuery と MVC で実践する標準志向 Web 開発
コーディング不要! Entity Framework 6.1.3 + ASP.NET MVC 5 サンプル アプリケーション構築 手順書
20200304 vuejs
Workspace ONE テクニカルガイド MDM
Building Silverlight Large Scale Application Using MVVM
Workspace one テクニカルガイド mcm
モバイルアプリケーション開発体験ハンズオン ~実装からビルド・テスト・ベータテスト配布まで~ Android 編

Similar to Windows ストア lob アプリ開発のためのガイダンスとフレームワークのご紹介 rev (20)

PDF
Vue入門
PDF
PHP 2大 web フレームワークの徹底比較!
PPTX
Xamarin.formsでのmvvm利用のコツ
PPTX
エンタープライズ分野での実践AngularJS
PDF
XAML と C# を使った Windows ストアアプリ(LOB)構築のためのtips Prism 4.5 & Kona project 等のご紹介
PDF
Tech talk salesforce mobile sdk
PDF
LabVIEW NXG Web Module Training Slide
PDF
Android test tutorial
PDF
ASP.NET MVC と jQuery で実践する標準志向 Web 開発
PPTX
MVPパターンによる設計アプローチ「あなたのアプリ報連相できてますか」
PDF
WordPress widget api
PDF
Hokuriku.NET ASP.NET MVC入門 「実践」 20120825
PDF
SpringMVCとmixer2で作るWebアプリのキホン 2013-01-24 Spring勉強会 #jsug
PDF
I Log On Saa S
PDF
Featuring Project Silk & Liike: 楽しい "モダン" Web 開発のちょっとディープなお話
PDF
Seasarプロジェクト徹底攻略
PDF
Application Architecture for Enterprise Win Store Apps with DDD Pattern
PDF
Google App Engineでできる、あんなこと/こんなこと
PPTX
Web リソースを活用した簡単アプリケーション開発(Windows Phone)
PDF
20091030cakephphandson 01
Vue入門
PHP 2大 web フレームワークの徹底比較!
Xamarin.formsでのmvvm利用のコツ
エンタープライズ分野での実践AngularJS
XAML と C# を使った Windows ストアアプリ(LOB)構築のためのtips Prism 4.5 & Kona project 等のご紹介
Tech talk salesforce mobile sdk
LabVIEW NXG Web Module Training Slide
Android test tutorial
ASP.NET MVC と jQuery で実践する標準志向 Web 開発
MVPパターンによる設計アプローチ「あなたのアプリ報連相できてますか」
WordPress widget api
Hokuriku.NET ASP.NET MVC入門 「実践」 20120825
SpringMVCとmixer2で作るWebアプリのキホン 2013-01-24 Spring勉強会 #jsug
I Log On Saa S
Featuring Project Silk & Liike: 楽しい "モダン" Web 開発のちょっとディープなお話
Seasarプロジェクト徹底攻略
Application Architecture for Enterprise Win Store Apps with DDD Pattern
Google App Engineでできる、あんなこと/こんなこと
Web リソースを活用した簡単アプリケーション開発(Windows Phone)
20091030cakephphandson 01
Ad

More from Shotaro Suzuki (20)

PDF
This is how our first offline technical event in three years was able to succ...
PDF
Introducing the new features of the Elastic 8.6 release.pdf
PDF
NET MAUI for .NET 7 for iOS, Android app development
PDF
What's New in the Elastic 8.5 Release
PDF
Centralized Observability for the Azure Ecosystem
PDF
What's New in the Elastic 8.4 Release
PDF
Power Apps x .NET ~ Transforming Business Applications with Fusion Development
PDF
devreljapan2022evaadvoc-final.pdf
PDF
elastic-mabl-co-webinar-20220729
PDF
Application development with c#, .net 6, blazor web assembly, asp.net web api...
PDF
Discover what's new in the Elastic 8.3 release - Find, monitor, and protect e...
PDF
Building a search experience with Elastic – Introducing Elastic's latest samp...
PDF
Developing .NET 6 Blazor WebAssemby apps with Radzen Blazor component library...
PDF
Elastic x Microsoft Azure Integration Evolution - Integrated Monitoring for S...
PDF
Building 3D mobile apps using Power Apps Mixed Reality controls, Azure SQL Da...
PDF
What's New in the Elastic 8.2 Release - Seamless User Experience with Search -
PDF
Application development with c#, .net 6, blazor web assembly, asp.net web api...
PDF
Building Software Reliability through Distributed Tracing.pdf
PDF
Building a Flutter Development Environment with VSCode and Useful Extensions
PDF
Application development with c#, .net 6, blazor web assembly, asp.net web api...
This is how our first offline technical event in three years was able to succ...
Introducing the new features of the Elastic 8.6 release.pdf
NET MAUI for .NET 7 for iOS, Android app development
What's New in the Elastic 8.5 Release
Centralized Observability for the Azure Ecosystem
What's New in the Elastic 8.4 Release
Power Apps x .NET ~ Transforming Business Applications with Fusion Development
devreljapan2022evaadvoc-final.pdf
elastic-mabl-co-webinar-20220729
Application development with c#, .net 6, blazor web assembly, asp.net web api...
Discover what's new in the Elastic 8.3 release - Find, monitor, and protect e...
Building a search experience with Elastic – Introducing Elastic's latest samp...
Developing .NET 6 Blazor WebAssemby apps with Radzen Blazor component library...
Elastic x Microsoft Azure Integration Evolution - Integrated Monitoring for S...
Building 3D mobile apps using Power Apps Mixed Reality controls, Azure SQL Da...
What's New in the Elastic 8.2 Release - Seamless User Experience with Search -
Application development with c#, .net 6, blazor web assembly, asp.net web api...
Building Software Reliability through Distributed Tracing.pdf
Building a Flutter Development Environment with VSCode and Useful Extensions
Application development with c#, .net 6, blazor web assembly, asp.net web api...
Ad

Windows ストア lob アプリ開発のためのガイダンスとフレームワークのご紹介 rev