There are two ways you can solve it.
First: Use Ribbon.SelectionChanged event. It will catch your ListBox SelectionChanged event too and you can add your logic to it.
private void RibbonSelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (e.OriginalSource is Ribbon)
{
//implement your logic
}
if (e.OriginalSource is ListBox)
{
//implement your logic
}
}
Second: I prefer to use ListView but I think its the same in this case. Create your custom ListBox with Click event.
public class RecentItemsList : System.Windows.Controls.ListView
{
public delegate void RecentItemClicked(object param);
public event RecentItemClicked Click;
public RecentItemsList()
{
SelectionChanged += RecentItemsList_SelectionChanged;
SetValue(ScrollViewer.HorizontalScrollBarVisibilityProperty, ScrollBarVisibility.Hidden);
//...
}
private void RecentItemsList_SelectionChanged(object sender, SelectionChangedEventArgs selectionChangedEventArgs)
{
if (SelectedIndex > -1)
{
//...
OnClick();
}
}
private void OnClick()
{
if (Click != null)
Click(null);
}
}