型 'EventToReactiveCommand' の値は、型 'TriggerActionCollection' のコレクションまたは辞書に追加できません。
3956 ワード
エラーメッセージ
型 '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
Author And Source
この問題について(型 'EventToReactiveCommand' の値は、型 'TriggerActionCollection' のコレクションまたは辞書に追加できません。), 我々は、より多くの情報をここで見つけました https://qiita.com/satorimon/items/55d109fd729627a39922著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .