LoginSignup

This article is a Private article. Only a writer and users who know the URL can access it.
Please change open range to public in publish setting if you want to share this article with other users.

More than 3 years have passed since last update.

[WPF] System.Windows.Interactivity は Microsoft.Xaml.Behaviors.Wpf に置き換え必要(2020年)

Posted at

もくじ
https://qiita.com/tera1707/items/4fda73d86eded283ec4f

やりたいこと

現在、WPFのアプリを作るときに、Commandプロパティを持たないコントロール(TextBlockとか)にコマンドを割り当てるために「System.Windows.Interactivity」を使用しているが、VisualStudio2017までのライブラリであって、VS2019以降にはこれに該当するライブラリが無いらしい。
※PRISM(MVVMのフレームワーク)を使っている場合は、PRISMがこれに依存している

ない、では困るので調べたところ、代替になるライブラリがオープンソースになって、Nugetから使えるようになっているとのこと。

自分ではまだ実施していないが、調べた際の有用なページ等をメモしておく。

やり方

「Microsoft.Xaml.Behaviors.Wpf」を使う。

対応方法

下記ページに対応方法がある。

〇MSのブログ
https://devblogs.microsoft.com/dotnet/open-sourcing-xaml-behaviors-for-wpf/

〇System.Windows.Interactivityに代わるMicrosoft.Xaml.Behaviors.Wpf
http://onechu312.blog.jp/archives/1074827701.html
シンプルにわかりやすくまとめてくれているページ。

VS2019で一時避難的に行っていたこと

上の対応方法の通りにやると、コードの中を修正する必要があるので、やりたくない、という場合は、VS2019使用時に一時避難的に下記を入れることでも対応可能。

  • Visual Studio Installer
    • 個別のコンポーネント
    • SDK、ライブラリ、およびフレームワーク
    • Blend for Visual Studio SDK for .NET

を選択してインストールする。
image.png

★関連記事
https://github.com/runceel/Livet/issues/27#issuecomment-496503752

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