LoginSignup
0
0

More than 5 years have passed since last update.

Prism入門(2)

Posted at

かずきさんのページを参考にPrismの勉強をしたので自分用のメモ
http://blog.okazuki.jp/entry/2014/04/27/025056
環境:Visual Studio 2017 Community

Prismのインストール

NuGetでPrism5.0.0をインストール

ViewModelの作成

「ViewModels」フォルダを作成し、その下に「ViewModelBase」クラスを作成。
「ValidationContext」「ValidationResult」「Validator」が見つからないとエラーになるので、「System.ComponentModel.DataAnnotations」の外部参照を追加する。
エラーが解消されたことを確認し、「MainWindowViewModel」クラスを追加する。

Viewの作成

「Views」フォルダを作成し、その下に「MainWindow.xaml」ファイルを移動する。
「名前 "Interaction" は名前空間 "http://schemas.microsoft.com/expression/2010/interactivity" に存在しません。」とコンパイルに失敗するので、NuGetで「Expression.Interaction」をインストールする。(現時点の安定バージョンは3.0.40218)

実行

実行するとSystem.IO.IOExceptionで、mainwindow.xamlを検索できないとなるので、App.xamlのStartupUriを"Views/MainWindow.xaml"に修正する。

メモ

ViewとViewModelのバインドは「Viewの名前+ViewModel」という命名規則で行っている。
PopupWindowActionの「CenterOverAssociatedObject」プロパティをtrueで画面中央に、「IsModal」プロパティをtrueで、モーダルにできる。

0
0
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
0
0