Scrolling a Disabled Listbox in WPF
Recently I had a requirement when developing an application,where i needed a listbox which was to be disabled but yet can be scrolled,so that all the contents in it was visible.Applying the property,IsEnabled=False makes the whole listbox disabled even disabling the scroll. I just found out a way around this.I created a custom listbox(MyScrollableListbox) with a property IsItemsEnabled.Setting this property to true,gives the normal listbox behaviour.When set to false only the ItemsPresenter of the listbox is disabled,so that scrolling is possible
The Custom Listbox looks like this(just one property added for now)
Public Class MyScrollableListboxInherits ListBoxPublic Property IsItemsEnabled() As BooleanGetReturn GetValue(IsItemsEnabledProperty)End GetSet(ByVal value As Boolean)SetValue(IsItemsEnabledProperty, value)End SetEnd PropertyPublic Shared ReadOnly IsItemsEnabledProperty As DependencyProperty = _DependencyProperty.Register("IsItemsEnabled", _GetType(Boolean), GetType(MyScrollableListbox), _New FrameworkPropertyMetadata(Nothing))End Class
In the xaml(or if you are going to make it a custom control then you can give it in your Generic.xaml)
Now if you set the property IsItemsEnabled to false the listbox will be disabled,but allowing you to scroll.
edit: Added in CodeProject
Hope it helps :)