44
Universal Windows Platform app 2015/8/8 Visual Studio 2015 リリース記念 勉強会 大田 一希

Visual Studio 2015 リリース記念 勉強会 universal windows platform app

  • Upload
    -

  • View
    1.833

  • Download
    0

Embed Size (px)

Citation preview

Universal Windows Platform app

2015/8/8 Visual Studio 2015 リリース記念勉強会

大田 一希

自己紹介

•名前/SNS• 大田 一希

• Twitter: @okazuki

• Blog• かずきのBlog@hatena

http://okazuki.hatenablog.com/

• その他• Microsoft MVP for Windows Platform Development

• Minecraftはじめました

• Spring Boot(Java)はじめました

お約束事項

•記載の内容は個人の見解であり、所属する企業を代表するものではありません。

今日のゴール

• Visual Studio 2015で追加されたUniversal Windows Platform appの概要と開発の雰囲気をつかんでもらう

Universal Windows Platform(UWP)まずは概要

Visual Studio 2015で開発できるアプリ(一部)

Visual Studio 2015

C#

Web ネイティブ

ASP.NET

従来のデスクトップ

Windows

FormsWPF

Xamarin

iOS

Windows 8

Windows

Phone

Windows

Store

app

Universal

Universal

Windows

Platform

app

And

roid

Visual Studio 2015で開発できるアプリ(一部)

Visual Studio 2015

C#

Web ネイティブ

ASP.NET

従来のデスクトップ

Windows

FormsWPF

Xamarin

iOS

Windows 8

Windows

Phone

Windows

Store

app

Universal

Universal

Windows

Platform

app

And

roid

Universal Windows Platform(UWP)

•以下の環境で動く• PC

• Desktop

• Tablet

• Mobile

• IoT

• Surface Hub

• Xbox

• HoloLens

• ワンバイナリ

Hello world(Demo(s))

• Visual Studio• Windows Universalから新規作成

• 1プロジェクト

• パソコン・電話で動く

アダプティブなUI(レスポンシブ)

12:38

Window title

Window title

電話

タブレット

デスクトップ

一般的なプラットフォーム

画面のブレークポイント

•電話(の中でも小さい)の画面• 320epx以下

12:38

画面のブレークポイント

• タブレットや大きめの電話や横画面の電話• 321epx~720epx

Window title

12:3

8

画面のブレークポイント

• デスクトップなどの画面• 720epx~1024epx

Window title

画面のブレークポイント

• デスクトップなどの大きな画面• 1024epx~

Window title

画面のブレークポイント

12:38

Window title

12:3

8

Window title

Window title

320epx 720epx 1024epx

アダプティブなコード

•状況に応じて呼び分け• 電話固有機能

• デスクトップ固有機能

特徴的な機能

特徴的な機能

•強化されたVisual State Manager

• RelativePanel

• SplitView

• AppBar

• ApiInformation

強化されたVisual State Manager

• VisualStateに以下のプロパティが追加された• StateTriggersこのステートに来るための条件を設定できる

• SetterStyleなどのSetterと同じ要領でプロパティの変更を書ける(プロパティを変えるためだけにStoryboardを書かなくてもいい)

強化されたVisual State Manager

AdaptiveTriggerでWindowの最小幅を指

定することが出来る。

その最小幅まではそのStateになる。

SetterのTargetでコントロール名.プロパティの

書式で変更対象を指定してValueで変更

後の値を指定する。

Demo(s)

RelativePanel

RelativePanel

• VisualTreeを深くせずに複雑なレイアウトが可能(らしい)

•相対位置によるレイアウト+Margin+Alignment• 画面の上下左右の端や中央

• とあるコントロールの上下左右の端や中央

• RelativePanel.LeftOf=“Button1”のように記述していく

RelativePanelの添付プロパティ

• Above: 上

• Bellow: 下

• RightOf: 右

• LeftOf: 左

• AlignRightWith: 指定したコントロールの右に合わせる

• AlignLeftWith: 指定したコントロールの左に合わせる

• AlignRightWithPanel: パネルの右に合わせる

• AlignLeftWithPanel: パネルの左に合わせる

• Top, Bottom, HorizontalCenter, VerticalCenter, etc…

RelativePanelWindow title

起点

LeftOf RightOf

Above

Bellow

RelativePanelWindow title

起点

AlightL

eftWith

AlighRig

htWith

AlignTopWith

AlignBottomWith

AlignVerticalCent

erWith

AlignHorizontalC

enterWith

RelativePanelWindow title

AlignTopWithPanel

AlignLeftWithPanel

AlignBottomWithPanel

AlignRightWithPanel

AlignVerticalCenterWithPanel

AlignHorizontalCenterWith

Panel

Demo(s)

SplitView

SplitView

俗に言うハンバーガーメニューを作る

コントロール

SplitView

Paneにメニュー部分

Contentに右側部分

SplitView

• DisplayMode表示形式• Inline

• インライン形式

• Overlay• 上にかぶさる形式

• CompactInline• 完全に隠れないInline

• CompactOverlay• 完全に隠れないOverlay

• IsPaneOpen• Paneが表示中かどうか

• CompactPaneLength• DisplayModeがCompactの時の表示幅

Demo(s)

おまけ

• アイコンはSegoe MDL2 Assetsの私用領域に入ってる

AppBar

AppBar

•画面下(上)に置けるボタンを配置するためのコントロール• UWPでは、画面の何処にでも置ける

• PrimaryCommandが初期状態で表示される

• SecondaryCommandが…を押したときにメニューっぽく表示される

• Contentプロパティに任意のコントロールを置ける

Demo(s)

アダプティブコード

以下のAPIを使って型が提供されているかどうかを判定して処理を書いていく。

• ApiInformation• IsTypePresent

• IsPropertyPresent

• IsEventPresent

• etc…

https://msdn.microsoft.com/ja-jp/library/windows.foundation.metadata.apiinformation.aspx

アダプティブコード

• “文字列”で型名などを指定します

Demo(s)

まとめ

まとめ

• Universal Windows Platform app• 様々なプラットフォームで1バイナリで動く

• PC

• Mobile

• SurfaceHub

• Xbox

• HoloLens

• アダプティブUI

• アダプティブコード

まとめ

• 強化されたVisual State Manager• AdaptiveTriggerでレスポンシブ対応が簡単に可能

• RelativePanel• VisualTreeを深くせず複雑なレイアウトが可能

• VSMと連携して再配置が容易

• SplitView• ハンバーガーメニュー

• AppBar• より汎用的なコントロールとなっている

• AppInformation• アダプティブなコードを書くための肝のAPI

まとめ

• Visual Studio 2015を使ってUWPを作りましょう!