/// <summary> /// Sets the automatic scroll. /// </summary> /// <param name="instance">The instance.</param> /// <param name="value">Value to set for Automatic scroll.</param> public static void SetAutoScroll(System.Windows.Controls.ListBox instance, bool value) { AutoScrollHandler oldHandler = (AutoScrollHandler)instance.GetValue(AutoScrollHandlerProperty); if (oldHandler != null) { oldHandler.Dispose(); instance.SetValue(AutoScrollHandlerProperty, null); } instance.SetValue(AutoScrollProperty, value); if (value) { instance.SetValue(AutoScrollHandlerProperty, new AutoScrollHandler(instance)); } }
/// <summary> /// Sets the automatic scroll. /// </summary> /// <param name="instance">The instance.</param> /// <param name="value">Value to set for Automatic scroll.</param> public static void SetAutoScroll(Controls.ListBox instance, bool value) { if (instance is null) { throw new ArgumentNullException(nameof(instance)); } AutoScrollHandler oldHandler = (AutoScrollHandler)instance.GetValue(AutoScrollHandlerProperty); if (oldHandler != null) { oldHandler.Dispose(); instance.SetValue(AutoScrollHandlerProperty, null); } instance.SetValue(AutoScrollProperty, value); if (value) { instance.SetValue(AutoScrollHandlerProperty, new AutoScrollHandler(instance)); } }