You can do this with a behavior, a simple solution wouldn't involve the VM at all:
public static class ScrollToSelectedBehavior
{
public static readonly DependencyProperty SelectedValueProperty = DependencyProperty.RegisterAttached(
"SelectedValue",
typeof(object),
typeof(ScrollToSelectedBehavior),
new PropertyMetadata(null, OnSelectedValueChange));
public static void SetSelectedValue(DependencyObject source, object value)
{
source.SetValue(SelectedValueProperty, value);
}
public static object GetSelectedValue(DependencyObject source)
{
return (object)source.GetValue(SelectedValueProperty);
}
private static void OnSelectedValueChange(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var listbox = d as ListBox;
listbox.ScrollIntoView(e.NewValue);
}
}
Which you would use like this:
<ListBox x:Name="lb1" ItemsSource="{Binding Items}" />
<ListBox x:Name="lb2" ItemsSource="{Binding Items}" behaviors:ScrollToSelectedBehavior.SelectedValue="{Binding ElementName=lb1, Path=SelectedValue}"/>
A slightly better solution would be to instead bind the behavior's DP to an object in the VM which raises an event whenever the selected value in listbox1 changes. That would expose this feature to the VM code and also allow for unit testing etc.