public static void SetHasBindableSelectedItems(System.Windows.Controls.ListView source, bool value) { SelectionChangedHandler Handler = (SelectionChangedHandler)source.GetValue(SelectionChangedHandlerProperty); if (value && Handler == null) { Handler = new SelectionChangedHandler(source); source.SetValue(SelectionChangedHandlerProperty, Handler); } else if (!value && Handler != null) { source.ClearValue(SelectionChangedHandlerProperty); } }