我正在使用 MVVM Light 制作 WPF 应用程序,并且我有以下 TreeView:
<TreeView x:Name="TreeView"
Grid.Column="2"
HorizontalAlignment="Left" Height="463.481" VerticalAlignment="Top" Width="263"
ItemsSource="{Binding PackageView}" Margin="0,5.657,0,0" Grid.Row="1" Grid.RowSpan="2" Grid.ColumnSpan="2">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectedItemChanged">
<i:InvokeCommandAction Command="{Binding Command}"
CommandParameter="SelectedItemChanged"/>
</i:EventTrigger>
</i:Interaction.Triggers>
<TreeView.ItemContainerStyle>
<Style TargetType="{x:Type TreeViewItem}">
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
<Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
<Setter Property="FontWeight" Value="Normal" />
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="FontWeight" Value="Bold" />
</Trigger>
</Style.Triggers>
</Style>
</TreeView.ItemContainerStyle>
When the selection is changed, I want to send the newly selected item as an argument to the command. 有没有办法做到这一点?我的印象是您可以使用 EventToCommand 执行此操作,但是当我尝试使用它们时,它说版本 4 不再支持它们,并且我找不到合适的解决方法。
谢谢。