Hi,
I'm using PRISM/MVVM and want to pass the currently selected item(s) in the data grid when a user selects a row, this is what I've got so far:
<i:Interaction.Triggers> <i:EventTrigger EventName="SelectedItemsChanged" SourceName="SchemeGrid"> <prism:InvokeCommandAction Command="{Binding SchemeSelectedCommand}" TriggerParameterPath="SelectedItems"></prism:InvokeCommandAction> </i:EventTrigger> </i:Interaction.Triggers>
I've tried various properties for the TriggerParameterPath but always get "object instance not set..." When I try using CommandParameter I receive a SelectedItemsChangedEventArgs object - I would like to receive just the selected item object if possible?
Many thanks as always
Since Jan 10, 2016, we can use TriggerParameterPath="Source.SelectedItems".
Please look at
https://github.com/PrismLibrary/Prism/issues/385
and
https://github.com/PrismLibrary/Prism/commit/1af5d9d61f3d92ec20bd52f32b5f24c6595a218e
Hello Michael,
TriggerParameterPath is used for passing a property in the event arguments of the event to the command. SelectedItems is not a property of SelectedItemsChangedEventArgs so that won't work. For a list of properties in SelectedItemsChangedEventArgs, please see the following: http://help.infragistics.com/doc/WPF/2014.1/CLR4.0/?page=InfragisticsWPF4.DataPresenter.v14.1~Infragistics.Windows.DataPresenter.Events.SelectedItemsChangedEventArgs_members.html
Now, the unfortunate thing is that your only real option would have been to use a TriggerParameterPath that looked something like this: "Source.SelectedItems", where "Source" would have been the XamDataGrid. The unforunate part about this is that you cannot use Source or OriginalSource as the TriggerParameterPath. I don't know why this is the case, but you can see this behavior if you try it with a Microsoft control like a TextBox.
What I recommend doing is creating a Blend behavior instead. You can create the behavior and attach it to the XamDataGrid, then inside the behavior you can handle the SelectedItemsChanged event and manually invoke the command, passing it whatever arguments you want.
Let me know if you have any questions on this.
Hi Michael,
I tested this in a sample and I see what you mean. I'm getting a NullReferenceException also.
I'm not too familiar with Prism's InvokeCommandAction's TriggerParameterPath as this is new to Prism 5 so I'm doing some research on this. I'll get back to you once I know more about this issue.
Sorry guys this should be in xamDataGrid - can someone move it for me?
Thanks