private static void OnIsRectSelectionEnabledChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { if (!(sender is ListBox)) { throw new ArgumentException("sender", "Target should be a ListBox and its sub class instance.");; } bool isEnabled = (bool)e.NewValue; if (isEnabled) { ListBoxRectSelection rectSelection = ListBoxExtention.GetRectSelection(sender); if (rectSelection == null) { rectSelection = new ListBoxRectSelection(sender as ListView); ListBoxExtention.SetRectSelection(sender, rectSelection); } rectSelection.IsEnabled = isEnabled; } }
private static void SetRectSelection(DependencyObject obj, ListBoxRectSelection value) { obj.SetValue(RectSelectionProperty, value); }