際際滷

際際滷Share a Scribd company logo
XAML /C# を聞った
Windows ストアアプリLOBB TIPS
- Prism 4.5 & Kona Project 吉のごB初 -

                   椳 嫗湊隻
                   テクニカルエバンジェリスト
                   惹 MTC ア`キテクト
                   晩云マイクロソフト幄塀氏芙
                   http://blogs.msdn.com/b/shosuz/
https://www.facebook.com/shosuz




テクニカルエバンジェリスト
 http://blogs.msdn.com/b/shosuz
MTC ア`キテクト
 http://www.microsoft.com/ja-jp/business/mtc/ads.aspx
曚ネタは麼に、Windows Azure, Windows、
Windows Phone, RIA, HTML5, MVVM,
iOS/Android x Windows AzureB亊, Guitar ´ 吉
ASPIC 茂侑T (`05 ~)
Wipse モバイル x クラウド何氏L─11 ~)
2005-2012 壼R弥寄僥寄僥垪掲械輩v、
2008-2010 嶄刹寄僥掲械輩v
Microsoft X咄S何 レ鶺5 (Gt./Key./DAW)
(2012 ゛)
アジェンダ
        ?
        ?
        ?

        ?

        ?
XAML と C# を聞った Windows ストアアプリLOBBのためのtips   Prism 4.5 & Kona project 吉のごB初
Windows ストア LOB アプリ
? LOB アプリケ`ションにも云鯉秘篇嶄の二Iが謹い
? n}としては
 ?   屡贋のアプリケ`ションとの慌贋の圭隈
 ?   _kリソ`スの_隠、室g冩俐吉
 ?   屡贋アプリケ`ションの札Q來_Jの}
 ?   Windows RT か Windows 8 Pro/Enterprise か
 ?   塘下の圭隈Windows ストア、SCCM、Active Directory、
               Intune、麿
XAML と C# を聞った Windows ストアアプリLOBBのためのtips   Prism 4.5 & Kona project 吉のごB初
デ`タソ`スとしてのxk岔
? ストアアプリケ`ションは児云議にデ`タベ`ス岷俊俊A音辛
? LOB アプリケ`ションはヘテロなh廠に弖紗される
   ?   仟、Bする and/or 屡贋のリレ`ショナルデ`タベ`ス
   ?   仟、帽_する and/or 屡贋の Web サ`ビス
   ?   仟、Bする and/or 屡贋のコンテンツサ`バ`
   ?   マスタ`デ`タが崔かれているサ`バ`, etc.
? ASP.NET MVC4 Web API か WCF Data Services か
   ?   デ`タベ`ス蒙に SQL Server は Data Services
   ?   サ`ビスの巷_だと Web API が嗤喘だが、LINQ で崙泙△
   ?   Data Services は RDBMS、Web API はそれ參翌のもの
   ?   Mみ栽わせて聞うWindows Azure の栽は Mobile Services もあり
為歯糾の糾n喘斌瞳カタログのフロ`箭
                                                                                                  XML-RPC
斌瞳秤                                                                                            マスタ`秤鵑碧
を碧
REST
           鮫 URLを
 7:37 AM
           根む斌瞳秤         鮫 URL                                                                              マスタ`
           鵑鯣ゝ          を碧                                                                          REST   秤鵑鯣ゝ
                           SharePoint Site                                                       se
                                          http://sharepoint/url                                  ar
                                                                                                 ch
                           Site Actions Browse         Page                                     username

                                    Parent > Parent > Current Page
                                       Page Title


                           Current Page
                                      Page One         Page Two      This Site: site   search




鮫馭鵑
                          Libraries
                          Site Pages
                          Shared
                          Documents




リクエスト           鮫 URL
                          Drop Off
                          Library
                          Custom
                          library




鮫馭鵑           を函誼
卦す
XAML と C# を聞った Windows ストアアプリLOBBのためのtips   Prism 4.5 & Kona project 吉のごB初
XAML と C# を聞った Windows ストアアプリLOBBのためのtips   Prism 4.5 & Kona project 吉のごB初
Entity Framework + Code First
? クラスを恬撹してデ`タベ`スを恬撹
  ?   System.ComponentModel.DataAnnotations
  ?   スキ`マ俐屎、マイグレ`ション辛嬬
  ?   テストデ`タを秘れられる
  ?   仟・稀`ビス羨ち貧げやマッシュアップサ`ビスのBニ`ズに栽崑


? ASP.NET MVC4 Web API でも WCF Data Services でも旋喘辛嬬
  ? ただし念宀の栽は、聞いやすいようにクラスOをすべき
XAML と C# を聞った Windows ストアアプリLOBBのためのtips   Prism 4.5 & Kona project 吉のごB初
Web API によるサ`ビスの巷_
? gに徭喇撹辛嬬
 ? コントロ`ラ兆Q協
 ? スキャフォ`ルディング
? オプションからxk
 ? テンプレ`ト
 ? モデルクラス
 ? デ`タコンテキストクラス
? クラスをm卷俐屎?弖紗
 ? メソッドの弖紗、吉
XAML と C# を聞った Windows ストアアプリLOBBのためのtips   Prism 4.5 & Kona project 吉のごB初
XAML と C# を聞った Windows ストアアプリLOBBのためのtips   Prism 4.5 & Kona project 吉のごB初
Kona プロジェクトとは
        ?

        ?




        ?
Kona Project とは
http://konaguidance.codeplex.com
? CodePlex に巷_された MVVM
  フレ`ムワ`ク
? Prism 4.5の匯何を旋喘
? C# / XAML に蒙晒
? Windows ストア LOB アプリ_k
  のために恷m晒
   ?   O協?碧チャ`ム
   ?   光フレ`ムへのw卞
   ?   バリデ`ション
   ?   その麿肝弖紗嚠協
その念に Prism C 圷?は´
WPF, Silverlight, Windows Phone _k喘
                     ?
                     ?
                     ?
                     ?

                     ?
                     ?
Prism は Windows ストアアプリ鬚か
               ?   Modularity
               ?   UI Composition
               ?   Region Navigation
               ?   Decoupled
                   Communication
               ?   Commands
               ?   MVVM Support
XAML と C# を聞った Windows ストアアプリLOBBのためのtips   Prism 4.5 & Kona project 吉のごB初
XAML と C# を聞った Windows ストアアプリLOBBのためのtips   Prism 4.5 & Kona project 吉のごB初
1. Windows Phone _kのUYを噴蛍に試喘する
 Windows Phone アプリ             Windows ストアアプリ
 Deactivate/Tombstoned/Reactiv Suspend/Terminate/Resume
 ate
 Microsoft Push Notification   Windows Push Notification
 Service (MPN)                 Service (WNS)
 Windows Phone Marketplace     Windows Store app certification
 certification                 & Application Excellence Review
                               (AER)
 App manifest declares         App manifest declares
 capabilities                  capabilities
2. AttachedBehavior にフォ`カスする
?    AttachedBehavior のUYを試
     かし、それにフォ`カス
     ? 瘁からコントロ`ルに嘛を弖紗できる
?    Blend のBehavior<T>
     ★ 聞わない
?    Expressions のバインディング
     ★ 聞わない
3. Push 宥岑には勣 Windows ストア_k宀鞠h
              ? Windows ストアに、_kした
                アプリを賦し、屎しいクレ
                デンシャルを函誼する
                (SID 式びシ`クレットキ`)
              ? 頼畠にサイドロ`ディングで
                塘下する念戻でO?_kを
                佩ったアプリからは、WNS
                (Windows Notification
                Service)を聞ったプッシュ塘
                佚はできない ★ 宥岑ハブ
4. .NET 4.5 の async と await を試喘する
async Task<int> AccessTheWebAsync()
{
        HttpClient client = new HttpClient();
        Task<string> getStringTask =
          client.GetStringAsync("http://msdn.microsoft.com");
        DoIndependentWork();
        string urlContents = await getStringTask;
        return urlContents.Length;
    }
ペ`ジ濡卞とナビゲ`ション
5. LayoutAwarePage クラスの聞喘
ペ`ジw卞、彜B砿尖、および Visual State の砿尖のため
Navigation support
         protected virtual void GoHome(object sender, RoutedEventArgs e)
         protected virtual void GoBack(object sender, RoutedEventArgs e)
         protected virtual void GoForward(object sender, RoutedEventArgs e)
Visual state switching
         public void StartLayoutUpdates(object sender, RoutedEventArgs e)
         public void StopLayoutUpdates(object sender, RoutedEventArgs e)
Process lifetime management
         protected override void OnNavigatedTo(NavigationEventArgs e)
         protected override void OnNavigatedFrom(NavigationEventArgs e)
         protected virtual void LoadState(Object navigationParameter,
                                                Dictionary<String, Object> pageState)
         protected virtual void SaveState(Dictionary<String, Object> pageState)
Navigation と Visual State のサポ`ト
XAML:
<Button Click="GoBack"
        IsEnabled="{Binding Frame.CanGoBack,
        ElementName=pageRoot}
        "Style="{StaticResource BackButtonStyle}^
/>
<UserControl
        Loaded="StartLayoutUpdates"
        Unloaded="StopLayoutUpdates^
>
LoadState と SaveState : SuspensionManager
protected override void SaveState(System.Collections.Generic.Dictionary<string, object> pageState)
{
    var virtualizingStackPanel =
                      VisualTreeUtilities.GetVisualChild<VirtualizingStackPanel>(itemGridView);
    if (virtualizingStackPanel != null && pageState != null)
    {
        pageState["virtualizingStackPanelHorizontalOffset"] = virtualizingStackPanel.HorizontalOffset;
    }
}


protected override void LoadState(object navigationParameter,
                                       System.Collections.Generic.Dictionary<string, object> pageState)
{
    if (pageState != null && pageState.ContainsKey("virtualizingStackPanelHorizontalOffset"))
    {
        double.TryParse(pageState["virtualizingStackPanelHorizontalOffset"].ToString(),
                        out virtualizingStackPanelHorizontalOffset);
    }
}
6. Visual State のサポ`トによる
   landscape, portrait, fill, and snap
<VisualStateManager.VisualStateGroups>
    <VisualStateGroup x:Name="ApplicationViewStates">
        <VisualState x:Name="FullScreenLandscape"/>
        <VisualState x:Name="Filled"/>
        <VisualState x:Name="FullScreenPortrait">
             <Storyboard>   ...   </Storyboard>
         </VisualState>
         <VisualState x:Name="Snapped">
             <Storyboard>   ...   </Storyboard>
         </VisualState>
     </VisualStateGroup>
</VisualStateManager.VisualStateGroups>
グロ`バル
7.グロ`バル -
 ロケ`ルごとに蛍xされたリソ`ス



    <ToolTip
        x:Uid=^PreviewCartoonizeAppBarButtonToolTip ̄
        Content=^Preview Cartoonization ̄
        ´ />
Model-View-ViewModel Pattern
8. ペ`ジw卞:
View First かViewModel First か
View First:
this.Frame.Navigate(typeof(ItemDetailPage), itemId);


ViewModel First:
Var itemDetailPageViewModel = new ItemDetailPageViewModel(´)
                                     { ItemId = itemId };
navigationService.Navigate(itemDetailPageViewModel);
9. BindableBase クラスの旋喘による
       INotifyPropertyChanged の戻工
public abstract class BindableBase : INotifyPropertyChanged
{
    public event PropertyChangedEventHandler PropertyChanged;

    protected bool SetProperty<T>(ref T storage, T value, [CallerMemberName] String propertyName = null)
    {
        if (object.Equals(storage, value)) return false;
        storage = value;
        this.OnPropertyChanged(propertyName);
        return true;
    }
    protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
    {
        var eventHandler = this.PropertyChanged;
        if (eventHandler != null)
        {
            eventHandler(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}
10. Kona ViewModelLocator の旋喘
?   Convention ベ`スのルックアップ
    ?   MyNamespace.MyPage -> MyNamespace.MyPageViewModel
?   ル`ルに児づく箭翌により Conventionのオ`バ`ライドが辛嬬
?   ViewModel をインスタンス晒するのにコンテナを試喘辛嬬
WPF/Silverlight における
    灸侏議なバリデ`ション
?   Implement INotifyDataErrorInfo
?   UI コントロ`ルでエラ`のディクショナリにバインド
    ?   NotifyOnValidationError=True

<TextBox Text="{Binding Id, Mode=TwoWay, ValidatesOnExceptions=True,
NotifyOnValidationError=True}"/>
11. Kona BindableValidator の旋喘
View:
<TextBox
           Text="{Binding Address.FirstName, Mode=TwoWay}"
           behaviors:HighlightFormFieldOnErrors.PropertyErrors=
           "{Binding Errors[FirstName]}" />
-----------------------------------------------------------------------------
ViewModel:
_bindableValidator = new BindableValidator(_address);


public BindableValidator Errors
{
    get { return _bindableValidator; }
}
Decoupled Eventing
           ?   ^ハリウッド塀ペアレンタル
               スタイルの UI コンポジション ̄
               (ユ`ザ`コントロ`ル)
           ?   徨コントロ`ルは、Lrg隔Aす
               るサ`ビスによりk伏したイベン
               トをリッスンする駅勣があるも、
               徭らそれを、函り翌すことはでき
               ない
           ?   Prism の EventAggregator 何蛍
               をポ`ティング
12. 駅勣に鬉犬 EventAggregator 聞喘
public SubscriberViewModel(IEventAggregator eventAggregator)
{
    eventAggregator.GetEvent<ShoppingCartUpdatedEvent>()
               .Subscribe(s => UpdateItemCountAsync());
}

public PublisherViewModel(IEventAggregator eventAggregator)
{
    _eventAggregator = eventAggregator;
}

_eventAggregator.GetEvent<ShoppingCartUpdatedEvent>()
               .Publish(string.Empty);
Commanding と ViewModel Method Invocation
ICommand:
         void Execute(object)
         bool CanExecute(object)
         event EventHandler CanExecuteChanged
Command Invoker:
         ButtonBase
-----------------------------------------------------
Event -> Action
13. コントロ`ルに
    ICommand をサポ`トする DelegateCommand を聞喘
View:
<Button Content=^Go to shopping cart ̄
 Command="{Binding ShoppingCartNavigationCommand}" />
---------------------------------------------------------------------
ViewModel:
ShoppingCartNavigationCommand = new
DelegateCommand(NavigateToShoppingCartPage,
                      CanNavigateToShoppingCartPage);

ShoppingCartNavigationCommand.RaiseCanExecuteChanged();
14. AttachedBehavior や Action を聞喘する
View:
<GridView x:Name="itemGridView^
         ItemsSource="{Binding Source={StaticResource groupedItemsViewSource}}"
         ItemTemplate="{StaticResource KonaRI250x250ItemTemplate}"
         SelectionMode="None^ IsItemClickEnabled="True"
         behaviors:ListViewItemClickedToAction.Action=
                  "{Binding CategoryNavigationAction}">
----------------------------------------------------------------------------------
ViewModel:
CategoryNavigationAction = NavigateToCategory;
Suspend, Resume, 式びTerminate
15. Kona RestorableStateAttribute と
    MVVM フレ`ムワ`クの旋喘
public class MyViewModel : ViewModel, INavigationAware
{
        private string _name;

       [RestorableState]
         public string Name
       {
           get { return _name; }
           set { SetProperty(ref _name, value); }
       }
}
16. Visual Studio とのy栽
    Windows              Windows
    Azure Store          Phone Store
ALM ソリュ`ションの戻工
ALM ソリュ`ションの戻工
クライアント

          Visual Studio Ultimate 2012
       アプリケ`ション ライフサイクル畠悶を淫凄議にカバ`

          Visual Studio Premium 2012
             y栽_kh廠とテストC嬬を喜d
 Visual Studio         Visual Studio
 Professional 2012     Test Professional 2012
 _kC嬬を戻工するy栽_kh廠        淫凄議なテストのg仏と砿尖を屶址


サ`バ`

  Visual Studio Team Foundation Server 2012
         アプリケ`ション_kプロジェクトのy栽_k児P
歌深秤
? Visual Studio 2012 秘並箭
   ? http://aka.ms/VS2012-Case
? Visual Studio 2012 が戻工するy栽ソリュ`ション
   ? http://aka.ms/VS2012-Sol
? Visual Studio 2012 u瞳ガイドPDF, 16MB)
   ? http://aka.ms/VS2012-Prod
? Visual Studio 2012 喘井
   ? http://aka.ms/VS2012-Try
? Visual Studio 2012 ライセンス ホワイトペ`パ`
   ? http://aka.ms/VS2012-Lic
Resource
? http://konaguidance.codeplex.com
  ? 哂Z井 OS でないと .exe は盾できない栽あり
  ? Source Code ★ Download で .zip を鯛としてください
XAML と C# を聞った Windows ストアアプリLOBBのためのtips   Prism 4.5 & Kona project 吉のごB初

More Related Content

What's hot (20)

PDF
JSON Schema で Web API のスキマを托めよう
VOYAGE GROUP
?
PPTX
ノンプログラミングで API はじめて悶Y_B表 敢直箆
kintone papers
?
PDF
Build insider testingwithvs
Tomoyuki Iwade
?
PDF
安艶恢粥壊壊艶馨恢鉛霞が俳り謡くフロントエンド安艶恢蝕kの隆栖
Jun-ichi Sakamoto
?
PPTX
パララックスでレスポンシブでJ query mobileなサイトのつくりかた
Shumpei Shiraishi
?
PDF
WebブラウザでC#g佩 WebAssemblyの室g
Sho Okada
?
PDF
Vs2013 multi device shosuz
Shotaro Suzuki
?
PPTX
粥永鴛モック3蛍クッキング
屓俛 署畢
?
PDF
Measuring Web Performance - 徭失祭磴能Kわらないためのパフォ`マンスy -
Koji Ishimoto
?
PPTX
オフラインファ`ストの房襪g樹
Shumpei Shiraishi
?
PDF
.NET の書と書瘁に房うこと
Akira Inoue
?
PDF
App Service の DevOps と Visual Studio Team Services 恷仟アップデ`ト
Microsoft Azure Japan
?
PDF
皆敬温乙乙艶姻で兵めるモデルファ`ストな粥永鴛蝕k
Takuro Sasaki
?
PDF
Service worker か?謡く mobile web の仟しいかたち
Kinuko Yasuda
?
PDF
.NET 6の豚棋の仟C嬬とアップデ`ト
TomomitsuKusaba
?
PPTX
粥皆永.鰻掘意楼誼の恷玉U揃を深賀する
Masaki Takeda
?
PDF
M晒する Web ゛ Progressive Web Apps のg廾と鮄 ゛
Microsoft Azure Japan
?
PDF
AngularとSpring Bootで恬るSPA + RESTful Web Serviceアプリケ`ション
ssuser070fa9
?
PPTX
webpackを聞ったワンランク貧のモダンJSカスタマイズ_T塁 疏箆
kintone papers
?
PPTX
サ`バ`レスで ガチ云桑\喘までやってるおし
Akira Nagata
?
JSON Schema で Web API のスキマを托めよう
VOYAGE GROUP
?
ノンプログラミングで API はじめて悶Y_B表 敢直箆
kintone papers
?
Build insider testingwithvs
Tomoyuki Iwade
?
安艶恢粥壊壊艶馨恢鉛霞が俳り謡くフロントエンド安艶恢蝕kの隆栖
Jun-ichi Sakamoto
?
パララックスでレスポンシブでJ query mobileなサイトのつくりかた
Shumpei Shiraishi
?
WebブラウザでC#g佩 WebAssemblyの室g
Sho Okada
?
Vs2013 multi device shosuz
Shotaro Suzuki
?
粥永鴛モック3蛍クッキング
屓俛 署畢
?
Measuring Web Performance - 徭失祭磴能Kわらないためのパフォ`マンスy -
Koji Ishimoto
?
オフラインファ`ストの房襪g樹
Shumpei Shiraishi
?
.NET の書と書瘁に房うこと
Akira Inoue
?
App Service の DevOps と Visual Studio Team Services 恷仟アップデ`ト
Microsoft Azure Japan
?
皆敬温乙乙艶姻で兵めるモデルファ`ストな粥永鴛蝕k
Takuro Sasaki
?
Service worker か?謡く mobile web の仟しいかたち
Kinuko Yasuda
?
.NET 6の豚棋の仟C嬬とアップデ`ト
TomomitsuKusaba
?
粥皆永.鰻掘意楼誼の恷玉U揃を深賀する
Masaki Takeda
?
M晒する Web ゛ Progressive Web Apps のg廾と鮄 ゛
Microsoft Azure Japan
?
AngularとSpring Bootで恬るSPA + RESTful Web Serviceアプリケ`ション
ssuser070fa9
?
webpackを聞ったワンランク貧のモダンJSカスタマイズ_T塁 疏箆
kintone papers
?
サ`バ`レスで ガチ云桑\喘までやってるおし
Akira Nagata
?

Viewers also liked (7)

PDF
Room metro Tokyo #3 k燕Y創です。
Manato KAMEYA
?
PPTX
Windows 8r旗のアプリ_k
佚岻 冫喟
?
PPTX
わんくま兆硬塁 #37 (20151114) Windows 10 UWP アプリ_k秘T(g樹)
Yasuhiko Yamamoto
?
PPTX
Anders Hejlsberg Q & A
佚岻 冫喟
?
PDF
安永酷蝕kでのりやすいF
Sho Okada
?
PPTX
遺#と鴛晦とネイティブと
佚岻 冫喟
?
PPTX
C#や.NET Frameworkがやっていること
佚岻 冫喟
?
Room metro Tokyo #3 k燕Y創です。
Manato KAMEYA
?
Windows 8r旗のアプリ_k
佚岻 冫喟
?
わんくま兆硬塁 #37 (20151114) Windows 10 UWP アプリ_k秘T(g樹)
Yasuhiko Yamamoto
?
Anders Hejlsberg Q & A
佚岻 冫喟
?
安永酷蝕kでのりやすいF
Sho Okada
?
遺#と鴛晦とネイティブと
佚岻 冫喟
?
C#や.NET Frameworkがやっていること
佚岻 冫喟
?
Ad

Similar to XAML と C# を聞った Windows ストアアプリLOBBのためのtips Prism 4.5 & Kona project 吉のごB初 (20)

PDF
Windows Azure ではじめる Windows ストアアプリ_k
Shotaro Suzuki
?
PDF
Net advantage 2012 volume2 恷仟秤 xaml プラットフォ`ム
Daizen Ikehara
?
PPTX
Web リソ`スを試喘したgアプリケ`ション_k(Windows Phone)
Akira Onishi
?
PPTX
仝Windows 8 ストア アプリ_k tips々 hokuriku.net vol.11 (2013定1埖26晩)
Fujio Kojima
?
PDF
Windows ストア lob アプリ_kのためのガイダンスとフレ`ムワ`クのごB初 rev
Shotaro Suzuki
?
PPTX
121117 metro styleapp_templateapp
Takayoshi Tanaka
?
PDF
patterns & practices "Project Silk" にる HTML5 とモダンブラウザのための Web _kの書瘁
Akira Inoue
?
PPTX
メトロスタイルアプリ_k 恷兜の匯i
ShinichiAoyagi
?
PDF
わんくま兆硬塁25(20121201) LT:仝_k悶Yテンプレ`トを聞ったストアアプリの恬撹々
Yasuhiko Yamamoto
?
PDF
jQuery と MVC でg樹する返章 Web _k
Akira Inoue
?
PPTX
Windows ストア アプリの貧返な恬り圭
匯錬 寄弥
?
PDF
皆庄鉛厩艶姻鉛庄乙鞄岳を譴犹畩渦坿點#19
Atsuo Yamasaki
?
PDF
2011定マイクロソフト テクノロジ`尅り卦り゛_k。
Takeshi Shinmura
?
PPTX
珂閣閣珂秘壇
Kazutoshi Urabe
?
PDF
Windowsストアアプリ_k オ`プンセミナ`レu
Akira Onishi
?
PPTX
Windows アプリケ`ション_k はじめに ゛ Windows アプリケ`ション_k兜僥宀の圭鬚 Visual Studio を聞ったアプリケ`ショ...
Fujio Kojima
?
PDF
Internet Explorer 9 の仟C嬬仝耕協サイト々 (Pinned sites)
shigeya
?
PDF
Application Architecture for Enterprise Win Store Apps with DDD Pattern
Atsushi Kambara
?
PDF
恷仟 ASP.NET Web _kオ`バ`ビュ`
Akira Inoue
?
PPTX
テンプレ`トを聞ったストアアプリの恬撹
Yasuhiko Yamamoto
?
Windows Azure ではじめる Windows ストアアプリ_k
Shotaro Suzuki
?
Net advantage 2012 volume2 恷仟秤 xaml プラットフォ`ム
Daizen Ikehara
?
Web リソ`スを試喘したgアプリケ`ション_k(Windows Phone)
Akira Onishi
?
仝Windows 8 ストア アプリ_k tips々 hokuriku.net vol.11 (2013定1埖26晩)
Fujio Kojima
?
Windows ストア lob アプリ_kのためのガイダンスとフレ`ムワ`クのごB初 rev
Shotaro Suzuki
?
121117 metro styleapp_templateapp
Takayoshi Tanaka
?
patterns & practices "Project Silk" にる HTML5 とモダンブラウザのための Web _kの書瘁
Akira Inoue
?
メトロスタイルアプリ_k 恷兜の匯i
ShinichiAoyagi
?
わんくま兆硬塁25(20121201) LT:仝_k悶Yテンプレ`トを聞ったストアアプリの恬撹々
Yasuhiko Yamamoto
?
jQuery と MVC でg樹する返章 Web _k
Akira Inoue
?
Windows ストア アプリの貧返な恬り圭
匯錬 寄弥
?
皆庄鉛厩艶姻鉛庄乙鞄岳を譴犹畩渦坿點#19
Atsuo Yamasaki
?
2011定マイクロソフト テクノロジ`尅り卦り゛_k。
Takeshi Shinmura
?
珂閣閣珂秘壇
Kazutoshi Urabe
?
Windowsストアアプリ_k オ`プンセミナ`レu
Akira Onishi
?
Windows アプリケ`ション_k はじめに ゛ Windows アプリケ`ション_k兜僥宀の圭鬚 Visual Studio を聞ったアプリケ`ショ...
Fujio Kojima
?
Internet Explorer 9 の仟C嬬仝耕協サイト々 (Pinned sites)
shigeya
?
Application Architecture for Enterprise Win Store Apps with DDD Pattern
Atsushi Kambara
?
恷仟 ASP.NET Web _kオ`バ`ビュ`
Akira Inoue
?
テンプレ`トを聞ったストアアプリの恬撹
Yasuhiko Yamamoto
?
Ad

More from Shotaro Suzuki (20)

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

XAML と C# を聞った Windows ストアアプリLOBBのためのtips Prism 4.5 & Kona project 吉のごB初

  • 1. XAML /C# を聞った Windows ストアアプリLOBB TIPS - Prism 4.5 & Kona Project 吉のごB初 - 椳 嫗湊隻 テクニカルエバンジェリスト 惹 MTC ア`キテクト 晩云マイクロソフト幄塀氏芙 http://blogs.msdn.com/b/shosuz/
  • 2. https://www.facebook.com/shosuz テクニカルエバンジェリスト http://blogs.msdn.com/b/shosuz MTC ア`キテクト http://www.microsoft.com/ja-jp/business/mtc/ads.aspx 曚ネタは麼に、Windows Azure, Windows、 Windows Phone, RIA, HTML5, MVVM, iOS/Android x Windows AzureB亊, Guitar ´ 吉 ASPIC 茂侑T (`05 ~) Wipse モバイル x クラウド何氏L─11 ~) 2005-2012 壼R弥寄僥寄僥垪掲械輩v、 2008-2010 嶄刹寄僥掲械輩v Microsoft X咄S何 レ鶺5 (Gt./Key./DAW) (2012 ゛)
  • 3. アジェンダ ? ? ? ? ?
  • 5. Windows ストア LOB アプリ ? LOB アプリケ`ションにも云鯉秘篇嶄の二Iが謹い ? n}としては ? 屡贋のアプリケ`ションとの慌贋の圭隈 ? _kリソ`スの_隠、室g冩俐吉 ? 屡贋アプリケ`ションの札Q來_Jの} ? Windows RT か Windows 8 Pro/Enterprise か ? 塘下の圭隈Windows ストア、SCCM、Active Directory、 Intune、麿
  • 7. デ`タソ`スとしてのxk岔 ? ストアアプリケ`ションは児云議にデ`タベ`ス岷俊俊A音辛 ? LOB アプリケ`ションはヘテロなh廠に弖紗される ? 仟、Bする and/or 屡贋のリレ`ショナルデ`タベ`ス ? 仟、帽_する and/or 屡贋の Web サ`ビス ? 仟、Bする and/or 屡贋のコンテンツサ`バ` ? マスタ`デ`タが崔かれているサ`バ`, etc. ? ASP.NET MVC4 Web API か WCF Data Services か ? デ`タベ`ス蒙に SQL Server は Data Services ? サ`ビスの巷_だと Web API が嗤喘だが、LINQ で崙泙△ ? Data Services は RDBMS、Web API はそれ參翌のもの ? Mみ栽わせて聞うWindows Azure の栽は Mobile Services もあり
  • 8. 為歯糾の糾n喘斌瞳カタログのフロ`箭 XML-RPC 斌瞳秤 マスタ`秤鵑碧 を碧 REST 鮫 URLを 7:37 AM 根む斌瞳秤 鮫 URL マスタ` 鵑鯣ゝ を碧 REST 秤鵑鯣ゝ SharePoint Site se http://sharepoint/url ar ch Site Actions Browse Page username Parent > Parent > Current Page Page Title Current Page Page One Page Two This Site: site search 鮫馭鵑 Libraries Site Pages Shared Documents リクエスト 鮫 URL Drop Off Library Custom library 鮫馭鵑 を函誼 卦す
  • 11. Entity Framework + Code First ? クラスを恬撹してデ`タベ`スを恬撹 ? System.ComponentModel.DataAnnotations ? スキ`マ俐屎、マイグレ`ション辛嬬 ? テストデ`タを秘れられる ? 仟・稀`ビス羨ち貧げやマッシュアップサ`ビスのBニ`ズに栽崑 ? ASP.NET MVC4 Web API でも WCF Data Services でも旋喘辛嬬 ? ただし念宀の栽は、聞いやすいようにクラスOをすべき
  • 13. Web API によるサ`ビスの巷_ ? gに徭喇撹辛嬬 ? コントロ`ラ兆Q協 ? スキャフォ`ルディング ? オプションからxk ? テンプレ`ト ? モデルクラス ? デ`タコンテキストクラス ? クラスをm卷俐屎?弖紗 ? メソッドの弖紗、吉
  • 17. Kona Project とは http://konaguidance.codeplex.com ? CodePlex に巷_された MVVM フレ`ムワ`ク ? Prism 4.5の匯何を旋喘 ? C# / XAML に蒙晒 ? Windows ストア LOB アプリ_k のために恷m晒 ? O協?碧チャ`ム ? 光フレ`ムへのw卞 ? バリデ`ション ? その麿肝弖紗嚠協
  • 18. その念に Prism C 圷?は´ WPF, Silverlight, Windows Phone _k喘 ? ? ? ? ? ?
  • 19. Prism は Windows ストアアプリ鬚か ? Modularity ? UI Composition ? Region Navigation ? Decoupled Communication ? Commands ? MVVM Support
  • 22. 1. Windows Phone _kのUYを噴蛍に試喘する Windows Phone アプリ Windows ストアアプリ Deactivate/Tombstoned/Reactiv Suspend/Terminate/Resume ate Microsoft Push Notification Windows Push Notification Service (MPN) Service (WNS) Windows Phone Marketplace Windows Store app certification certification & Application Excellence Review (AER) App manifest declares App manifest declares capabilities capabilities
  • 23. 2. AttachedBehavior にフォ`カスする ? AttachedBehavior のUYを試 かし、それにフォ`カス ? 瘁からコントロ`ルに嘛を弖紗できる ? Blend のBehavior<T> ★ 聞わない ? Expressions のバインディング ★ 聞わない
  • 24. 3. Push 宥岑には勣 Windows ストア_k宀鞠h ? Windows ストアに、_kした アプリを賦し、屎しいクレ デンシャルを函誼する (SID 式びシ`クレットキ`) ? 頼畠にサイドロ`ディングで 塘下する念戻でO?_kを 佩ったアプリからは、WNS (Windows Notification Service)を聞ったプッシュ塘 佚はできない ★ 宥岑ハブ
  • 25. 4. .NET 4.5 の async と await を試喘する async Task<int> AccessTheWebAsync() { HttpClient client = new HttpClient(); Task<string> getStringTask = client.GetStringAsync("http://msdn.microsoft.com"); DoIndependentWork(); string urlContents = await getStringTask; return urlContents.Length; }
  • 27. 5. LayoutAwarePage クラスの聞喘 ペ`ジw卞、彜B砿尖、および Visual State の砿尖のため Navigation support protected virtual void GoHome(object sender, RoutedEventArgs e) protected virtual void GoBack(object sender, RoutedEventArgs e) protected virtual void GoForward(object sender, RoutedEventArgs e) Visual state switching public void StartLayoutUpdates(object sender, RoutedEventArgs e) public void StopLayoutUpdates(object sender, RoutedEventArgs e) Process lifetime management protected override void OnNavigatedTo(NavigationEventArgs e) protected override void OnNavigatedFrom(NavigationEventArgs e) protected virtual void LoadState(Object navigationParameter, Dictionary<String, Object> pageState) protected virtual void SaveState(Dictionary<String, Object> pageState)
  • 28. Navigation と Visual State のサポ`ト XAML: <Button Click="GoBack" IsEnabled="{Binding Frame.CanGoBack, ElementName=pageRoot} "Style="{StaticResource BackButtonStyle}^ /> <UserControl Loaded="StartLayoutUpdates" Unloaded="StopLayoutUpdates^ >
  • 29. LoadState と SaveState : SuspensionManager protected override void SaveState(System.Collections.Generic.Dictionary<string, object> pageState) { var virtualizingStackPanel = VisualTreeUtilities.GetVisualChild<VirtualizingStackPanel>(itemGridView); if (virtualizingStackPanel != null && pageState != null) { pageState["virtualizingStackPanelHorizontalOffset"] = virtualizingStackPanel.HorizontalOffset; } } protected override void LoadState(object navigationParameter, System.Collections.Generic.Dictionary<string, object> pageState) { if (pageState != null && pageState.ContainsKey("virtualizingStackPanelHorizontalOffset")) { double.TryParse(pageState["virtualizingStackPanelHorizontalOffset"].ToString(), out virtualizingStackPanelHorizontalOffset); } }
  • 30. 6. Visual State のサポ`トによる landscape, portrait, fill, and snap <VisualStateManager.VisualStateGroups> <VisualStateGroup x:Name="ApplicationViewStates"> <VisualState x:Name="FullScreenLandscape"/> <VisualState x:Name="Filled"/> <VisualState x:Name="FullScreenPortrait"> <Storyboard> ... </Storyboard> </VisualState> <VisualState x:Name="Snapped"> <Storyboard> ... </Storyboard> </VisualState> </VisualStateGroup> </VisualStateManager.VisualStateGroups>
  • 32. 7.グロ`バル - ロケ`ルごとに蛍xされたリソ`ス <ToolTip x:Uid=^PreviewCartoonizeAppBarButtonToolTip ̄ Content=^Preview Cartoonization ̄ ´ />
  • 34. 8. ペ`ジw卞: View First かViewModel First か View First: this.Frame.Navigate(typeof(ItemDetailPage), itemId); ViewModel First: Var itemDetailPageViewModel = new ItemDetailPageViewModel(´) { ItemId = itemId }; navigationService.Navigate(itemDetailPageViewModel);
  • 35. 9. BindableBase クラスの旋喘による INotifyPropertyChanged の戻工 public abstract class BindableBase : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; protected bool SetProperty<T>(ref T storage, T value, [CallerMemberName] String propertyName = null) { if (object.Equals(storage, value)) return false; storage = value; this.OnPropertyChanged(propertyName); return true; } protected void OnPropertyChanged([CallerMemberName] string propertyName = null) { var eventHandler = this.PropertyChanged; if (eventHandler != null) { eventHandler(this, new PropertyChangedEventArgs(propertyName)); } } }
  • 36. 10. Kona ViewModelLocator の旋喘 ? Convention ベ`スのルックアップ ? MyNamespace.MyPage -> MyNamespace.MyPageViewModel ? ル`ルに児づく箭翌により Conventionのオ`バ`ライドが辛嬬 ? ViewModel をインスタンス晒するのにコンテナを試喘辛嬬
  • 37. WPF/Silverlight における 灸侏議なバリデ`ション ? Implement INotifyDataErrorInfo ? UI コントロ`ルでエラ`のディクショナリにバインド ? NotifyOnValidationError=True <TextBox Text="{Binding Id, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True}"/>
  • 38. 11. Kona BindableValidator の旋喘 View: <TextBox Text="{Binding Address.FirstName, Mode=TwoWay}" behaviors:HighlightFormFieldOnErrors.PropertyErrors= "{Binding Errors[FirstName]}" /> ----------------------------------------------------------------------------- ViewModel: _bindableValidator = new BindableValidator(_address); public BindableValidator Errors { get { return _bindableValidator; } }
  • 39. Decoupled Eventing ? ^ハリウッド塀ペアレンタル スタイルの UI コンポジション ̄ (ユ`ザ`コントロ`ル) ? 徨コントロ`ルは、Lrg隔Aす るサ`ビスによりk伏したイベン トをリッスンする駅勣があるも、 徭らそれを、函り翌すことはでき ない ? Prism の EventAggregator 何蛍 をポ`ティング
  • 40. 12. 駅勣に鬉犬 EventAggregator 聞喘 public SubscriberViewModel(IEventAggregator eventAggregator) { eventAggregator.GetEvent<ShoppingCartUpdatedEvent>() .Subscribe(s => UpdateItemCountAsync()); } public PublisherViewModel(IEventAggregator eventAggregator) { _eventAggregator = eventAggregator; } _eventAggregator.GetEvent<ShoppingCartUpdatedEvent>() .Publish(string.Empty);
  • 41. Commanding と ViewModel Method Invocation ICommand: void Execute(object) bool CanExecute(object) event EventHandler CanExecuteChanged Command Invoker: ButtonBase ----------------------------------------------------- Event -> Action
  • 42. 13. コントロ`ルに ICommand をサポ`トする DelegateCommand を聞喘 View: <Button Content=^Go to shopping cart ̄ Command="{Binding ShoppingCartNavigationCommand}" /> --------------------------------------------------------------------- ViewModel: ShoppingCartNavigationCommand = new DelegateCommand(NavigateToShoppingCartPage, CanNavigateToShoppingCartPage); ShoppingCartNavigationCommand.RaiseCanExecuteChanged();
  • 43. 14. AttachedBehavior や Action を聞喘する View: <GridView x:Name="itemGridView^ ItemsSource="{Binding Source={StaticResource groupedItemsViewSource}}" ItemTemplate="{StaticResource KonaRI250x250ItemTemplate}" SelectionMode="None^ IsItemClickEnabled="True" behaviors:ListViewItemClickedToAction.Action= "{Binding CategoryNavigationAction}"> ---------------------------------------------------------------------------------- ViewModel: CategoryNavigationAction = NavigateToCategory;
  • 45. 15. Kona RestorableStateAttribute と MVVM フレ`ムワ`クの旋喘 public class MyViewModel : ViewModel, INavigationAware { private string _name; [RestorableState] public string Name { get { return _name; } set { SetProperty(ref _name, value); } } }
  • 46. 16. Visual Studio とのy栽 Windows Windows Azure Store Phone Store
  • 49. クライアント Visual Studio Ultimate 2012 アプリケ`ション ライフサイクル畠悶を淫凄議にカバ` Visual Studio Premium 2012 y栽_kh廠とテストC嬬を喜d Visual Studio Visual Studio Professional 2012 Test Professional 2012 _kC嬬を戻工するy栽_kh廠 淫凄議なテストのg仏と砿尖を屶址 サ`バ` Visual Studio Team Foundation Server 2012 アプリケ`ション_kプロジェクトのy栽_k児P
  • 50. 歌深秤 ? Visual Studio 2012 秘並箭 ? http://aka.ms/VS2012-Case ? Visual Studio 2012 が戻工するy栽ソリュ`ション ? http://aka.ms/VS2012-Sol ? Visual Studio 2012 u瞳ガイドPDF, 16MB) ? http://aka.ms/VS2012-Prod ? Visual Studio 2012 喘井 ? http://aka.ms/VS2012-Try ? Visual Studio 2012 ライセンス ホワイトペ`パ` ? http://aka.ms/VS2012-Lic
  • 51. Resource ? http://konaguidance.codeplex.com ? 哂Z井 OS でないと .exe は盾できない栽あり ? Source Code ★ Download で .zip を鯛としてください