型 'EventToReactiveCommand' の値は、型 'TriggerActionCollection' のコレクションまたは辞書に追加できません。


エラーメッセージ

型 'EventToReactiveCommand' の値は、型 'TriggerActionCollection' のコレクションまたは辞書に追加できません。

への対処。
System.Windows.Window.InteractivityではなくMicrosoft.Xaml.Behaviors.Wpfを使いましょう。

理由はこの辺みたいです。

WPF のビヘイビアーが入ってる Blend SDK for Visual Studio が Visual Studio 2019 で消えた件について

EventToReactiveCommandを使おうとしたけど例外!!

MVVM でイベント引数の値を ViewModel のコマンドに渡す方法を参考にやってみたらタイトルの例外で落ちてしまいました。

検索してみたら冒頭の情報とTwitterに辿り着きossの方のInteractivityを使うようにしたらすっと動きました。
地味に時間かかって悔しい。

具体的にはこんな感じです。

<Window x:Class="TestEventToReactiveCommand.Views.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:prism="http://prismlibrary.com/"

        xmlns:behaviours="http://schemas.microsoft.com/xaml/behaviors"
        xmlns:interactivity="clr-namespace:Reactive.Bindings.Interactivity;assembly=ReactiveProperty.WPF"

        xmlns:local="clr-namespace:TestEventToReactiveCommand"
        prism:ViewModelLocator.AutoWireViewModel="True"
        Title="{Binding Title}" Height="350" Width="525">

    <behaviours:Interaction.Triggers>
        <behaviours:EventTrigger EventName="MouseMove">
            <interactivity:EventToReactiveCommand Command="{Binding MouseMoveCommand}">
                <local:MouseMoveToMousePositionConverter />
            </interactivity:EventToReactiveCommand>
        </behaviours:EventTrigger>
    </behaviours:Interaction.Triggers>

    <Grid>
        <ContentControl prism:RegionManager.RegionName="ContentRegion" />
        <TextBlock
            HorizontalAlignment="Center"
            VerticalAlignment="Center"
            Text="{Binding Message.Value}" />
    </Grid>
</Window>

なんか私の場合はNugetで Microsoft.Xaml.Behaviors.Wpf を追加しないでも動いてますが、
ここによれば追加しろと書いてある??

ざっと動かしただけですが確認したソース
TestEventToReactiveCommand