More Related Content Similar to Xamarin.Forms.WPF を試してみた (20) More from m ishizaki (20) Xamarin.Forms.WPF を試してみた2. / 60
自己紹介
石崎 充良 ( @mishi_cs )
Japan Xamarin Users Group ( JXUG )
Microsoft MVP for Visual Studio and Development Technologies
言語: C# XAML
活動:
・JXUG (もくもく会) (connpass)
・城東.NET Users Group (connpass)
・C# もくもく会 (connpass)
※主に秋葉原
2
6. / 60
Xamarin とは
・Android / iOS の API を C# から使えるようにしたもの
・C# (.NET) のライブラリを使えるようにしたもの
6
ロジックのみ共通化
UIはネイティブで個別に作りこむ
Shared C# App Logic
(.NET Standard)
iOS
C# UI
Android
C# UI
Windows
C# UI
7. / 60
Xamarin の2つの開発方法
7
Xamarin Native Xamarin Forms
ロジックのみ共通化
UIはネイティブで個別に作りこむ
ロジックとUIを共通化
UIは各プラットフォームの
同じ役割のUIが自動マッピング
Shared C# App Logic
(.NET Standard)
iOS
C# UI
Android
C# UI
Windows
C# UI
Shared C# App Logic
(.NET Standard)
Shared C# UI Code
(Xamarin.Forms)
9. / 60
UI の開発手法
9
Xamarin.Native Xamarin.Forms
概要 ネイティブの技術を使用 UI 共通化ライブラリ
定義 Android では axml
iOS では storyboard など
xaml というシンプルな XML
制約 制限のない UI 各プラットフォームの最大公約数の機能
のみ
特徴 UI が共通化できない UI にこだわらないアプリなら UI まで共
通化可能
使いどころ コンシューマー向けアプリやデザ
インを重視する場合に
ビジネス向けアプリや機能重視のツール
系アプリなどに
Formsで細
かくUIを定
義したい
Custom Renderer で独自にネイティブの
コントロール/プロパティと結合するコン
トロールを作成可能
10. / 60
C# (.NET) のライブラリ
全体像
10
Xamarin
コード共有
Xamarin.Navive Xamarin.Forms.axml /
storyboard
Xamarin.Android
Xamarin.iOS
UI の定義UI の定義 どちらか選択
16. / 60
Xamarin.Forms 使われるクラス (スーパークラス)
StackLayout Xamarin.Forms.Platform.WPF.FormsPanel Panel
AbsoluteLayout Xamarin.Forms.Platform.WPF.FormsPanel Panel
RelativeLayout Xamarin.Forms.Platform.WPF.FormsPanel Panel
Grid Xamarin.Forms.Platform.WPF.FormsPanel Panel
ContentView Xamarin.Forms.Platform.WPF.FormsPanel Panel
ScrollView ScrollViewer
Frame Border
ActivityIndicator ProgressBar
BoxView System.Windows.Shapes.Rectangle
Button Button
DatePicker DatePicker
Editor TextBox
Entry Xamarin.Forms.Platform.WPF.FormsTextBox TextBox
Image Image
Label TextBlock
ListView ListView
Map Microsoft.Maps.MapControl.Map
OpenGLView
System.Windows.Forms.Integration.WindowsFormsHost
-> OpenTK.GLControl UserControl
Picker ComboBox
ProgressBar ProgressBar
SearchBar Xamarin.Forms.Platform.WPF.FormsTextBox TextBox
Slider Slider
Stepper <Border><StackPanel><Button/><Button/></StackPanel></Border>
Switch CheckBox
TableView ListView
TimePicker Xamarin.Forms.Platform.WPF.FormsTimePicker TextBox
WebView WebBrowser
EntryCell Xamarin.Forms.Platform.WPF.FormsTextBox TextBox
ImageCell <Grid><Image/><TextBlock/><TextBlock/></Grid>
SwitchCell <Grid><TextBlock/><CheckBox/></Grid>
TextCell <StackPanel><TextBlock/><TextBlock/></StackPanel> 16
17. / 60
コントロールのマッピング (1)
Xamarin.Forms 使われるクラス (スーパークラス)
StackLayout Xamarin.Forms.Platform.WPF.FormsPanel Panel
AbsoluteLayout Xamarin.Forms.Platform.WPF.FormsPanel Panel
RelativeLayout Xamarin.Forms.Platform.WPF.FormsPanel Panel
Grid Xamarin.Forms.Platform.WPF.FormsPanel Panel
ContentView Xamarin.Forms.Platform.WPF.FormsPanel Panel
ScrollView ScrollViewer
Frame Border
ActivityIndicator ProgressBar
BoxView System.Windows.Shapes.Rectangle
Button Button
DatePicker DatePicker
Editor TextBox
Entry Xamarin.Forms.Platform.WPF.FormsTextBox TextBox
Image Image
Label TextBlock
ListView ListView
Map Microsoft.Maps.MapControl.Map 17
18. / 60
コントロールのマッピング (2)
Xamarin.Forms 使われるクラス (スーパークラス)
OpenGLView
System.Windows.Forms.Integration.WindowsFormsHost
-> OpenTK.GLControl UserControl
Picker ComboBox
ProgressBar ProgressBar
SearchBar Xamarin.Forms.Platform.WPF.FormsTextBox TextBox
Slider Slider
Stepper
<Border><StackPanel><Button/><Button/>
</StackPanel></Border>
TableView ListView
TimePicker Xamarin.Forms.Platform.WPF.FormsTimePicker TextBox
WebView WebBrowser
EntryCell Xamarin.Forms.Platform.WPF.FormsTextBox TextBox
ImageCell <Grid><Image/><TextBlock/><TextBlock/></Grid>
SwitchCell <Grid><TextBlock/><CheckBox/></Grid>
TextCell <StackPanel><TextBlock/><TextBlock/></StackPanel>
ViewCell Xamarin.Forms.Platform.WPF.CellControl ContentControl
18
43. / 60
Bing ると
• bin (+obj) を消してリビルドしろという情報
• ただし、ASP.NET の情報
43
試してみた
44. / 60
Bing ると
• bin (+obj) を消してリビルドしろという情報
• ただし、ASP.NET の情報
44
試してみた
効果なし
48. / 60
インストール
48
[コマンド]
gacutil -i netfx.force.conflicts.dll
[Assembly の場所]
C:Program Files (x86)Microsoft Visual
Studio2017EnterpriseMSBuildMicrosoftMicrosoft.NET.Build.Extensionsnet461lib
60. / 60
まとめ
• ちゃんと UI を構築できる
• WPF の既存の設定ファイルがある
• インストーラも(今のところ問題はあるが)ちゃんと作れる
• 既存 Xamarin アプリの UI もそのまま使える
• 既存 Xamarin アプリのロジックも(簡単な検証だが)動作する
結論
• 十分使える方向で育ってきている
※使いどころがあるかどうかは別の話。アイデアは無限。
60