.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month

Home >> Articles >> WPF >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Scrollable Disabled ListBox in WPF

Posted By:Rahul       Posted Date: September 13, 2010    Points: 25    Category: WPF    URL: http://www.dotnetspark.com  

This is show a custom listbox that can be scrolled even when it is disabled

Many of you developing applications in WPF might have had the need to keep a ListBox disabled yet scroll it so that you can see the items in it. Say, in case you want to show the details to the user who can just view the details presented and not edit it, and some of the details might happen to be in a ListBox

As for the code, it is very simple. All I have done is created a custom control derived from ListBox, and added a Dependency Property, IsEnabledWithScroll. This property is directly bound with the IsEnabled property of the ItemsPresenter of the ListBox. By doing this, the scroll viewer is enabled even when the items are disabled.

I have changed the control template to reflect this, as shown below:

You can always go ahead modifying the template, but remember to bind the ItemsPresenter IsEnabled property to the IsEnabledWithScroll property.

With this control in place, you should not be using the IsEnabled property of the ListBox. Go ahead and use the IsEnabledWithScroll property to enable/disable your control. Of course, you have the scrollable option enabled.
 Subscribe to Articles


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend