1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

初めての WinUI 3 (4) コマンド

Posted at

前回

前回は、WinUI 3のカスタムコントロールについて学習しました。

今回

今回は、コマンド(ICommand)についてやってみよう。

コマンドって何?

WinUIにおけるMVVMのコマンドとは、MVVM(Model-View-ViewModel)アーキテクチャにおいて、UI(View)とViewModelの間で、ユーザー操作やアクションを処理するために使用されるインターフェース、またはそのインターフェースを実装したオブジェクトです。

実装してみる

完成品はこちら。

ユーザー登録時
image.png

パスワード変更時
image.png

ユーザー削除時
image.png

ソースはGithubでご確認ください。

まとめ

  • ICommandを実装するのだけれど、MVVM Community Toolkitを使うならReleyCommandAttributeが楽
  • 画面操作で直接コマンドを動かすときは、XAMLにCommand属性とComamndParameterを{x:Bind}する
  • ContentDialogを経由する場合は、Clickイベントを実装してダイアログを表示してダイアログのボタンにCommandを設定する
  • グループヘッダーありリストビューが無駄にお洒落

また、次回があればどうぞ。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?