<ListBox x:Name="lbx"
SelectedIndex="0"
ItemsSource="{Binding BooksCollection,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
VirtualizingPanel.IsContainerVirtualizable="True"
VirtualizingPanel.IsVirtualizing="True"
VirtualizingPanel.ScrollUnit="Item"
VirtualizingPanel.VirtualizationMode="Recycling">
<behavior:Interaction.Triggers>
<behavior:EventTrigger EventName="SelectionChanged">
<behavior:InvokeCommandAction Command="{Binding SelectionChangedCmd}"
CommandParameter="{Binding Path=SelectedItem,
RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type ListBox}}}"/>
</behavior:EventTrigger>
</behavior:Interaction.Triggers>
</ListBox>
//cs
private void InitCmds()
{
SelectionChangedCmd = new DelCmd(SelectionChangedCmdExecuted);
}
private void SelectionChangedCmdExecuted(object obj)
{
var bk = obj as Book;
if (bk != null)
{
ImgTitle = bk.Name;
MessageBox.Show(ImgTitle, "Image Title", MessageBoxButton.OK);
}
}
![]()