Hi,@RogerSchlueter-7899. Welcome to Microsoft Q&A.
It is likely due to the way you're trying to bind the CommandParameter of the InvokeCommandAction. In your XAML, you're trying to bind to SelectedValue directly, but SelectedValue is not directly accessible in the context of the CommandParameter binding within the InvokeCommandAction.
You could use a RelativeSource binding to access the SelectedValue property of the ListBox.
<ListBox
DisplayMemberPath="Name"
ItemsSource="{Binding Path=GeoElements}"
SelectedValue="{Binding Path=RouteID}"
SelectedValuePath="ElementID" >
<i:Interaction.Triggers>
<i:EventTrigger
EventName="SelectionChanged">
<i:InvokeCommandAction
Command="{Binding Path=SelectRoute}"
CommandParameter="{Binding Path=SelectedValue}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</ListBox>
This change will ensure that the CommandParameter
is correctly bound to the SelectedValue
of the ListBox
. Now, when an item is selected in the ListBox
, the DoSelectRoute
method in your view model should receive the correct value for obj
.
My test result:
![User's image](https://learn-attachment.microsoft.com/api/attachments/62e57524-d852-46be-8d0a-62fb2812fdda?platform=QnA)
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.