private static void OnListBoxSelectionChanged(object sender, SelectionChangedEventArgs e)
{
ListBox listBox = sender as ListBox; if (listBox != null)
{
//BindingExpression bexp = listBox.GetBindingExpression(SelectedItemsSourceProperty);
//bexp.UpdateSource();
bool isResynching = (bool)listBox.GetValue(IsResynchingPropertyKey.DependencyProperty);
if (isResynching)
return;
IList list = GetSelectedItemsSource(listBox);
if (list != null)
{
foreach (object obj in e.RemovedItems)
{
if (list.Contains(obj))
list.Remove(obj);
}
foreach (object obj in e.AddedItems)
{
if (!list.Contains(obj))
list.Add(obj);
}
}
}
}