Xamarin.Forms のプレビュー版ではクラシックデスクトップアプリが作れるので試してみています。
まずは一通りコントロールを表示してそれぞれ WPF のどのコントロールにマッピングされるのかを見てみた話です。
まず Xamarin.Forms でクラシックデスクトップアプリの作り方から、という方は次の記事が参考になるかもしれません。
■ 確認方法
クラシックデスクトップアプリでは、UI の確認は非常に簡単です。
何もしなくても、標準で確認のための機能が備わっています。
※WPF のデバッグの様子
この画面上端中央の黒いコントロール。
皆が大嫌いな『WPF を初めて触るベテランエンジニア皆が最初に「こいつを消す方法」を聞いてくる非常に有益なツール』です。
日本語では XAML の UI デバッグツール
というらしいです。
このツールをクリックするだけで、実際に生成されている UI コントロールやプロパティを確認することができます。
とても便利!
このツールのおかげで、謎の見えないコントロールにクリックが吸われたり、コントロールがどこか見えない場所に隠れたりといった悩みとは無縁です。
この便利ツールを使って、実際に表示されているコントロールを確認するだけでマッピングが確認できます。
■ 確認結果
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> | |
ViewCell | Xamarin.Forms.Platform.WPF.CellControl | ContentControl |
そのままなマッピングもありますが、StackLayout が独自に定義した Panel のサブクラスだったりと結構いろいろありますね。
次はそれらの独自コントロールがどのような機能拡張がされているか確認してみたいところですが、今回はここまで。