WPF Guru - Set Brush for ScrollViewer Thumb

It's time for another TechNet Guru winner!

Congratulations to Khanna Gaurav, an MCC and our WPF Guru winner for June 2013! To find all the competitors for June (and more information about this monthly contest), see the Wiki article: TechNet Guru Contributions for June 2013.

  

Khanna Gaurav's avatar

About Khanna: He is the founder of Volcor Software, Microsoft Community Contributor (MCC) and Microsoft MVP from Ahmedabad, India.

 

Khanna won with this fantastic contribution:

 Set Brush for ScrollViewer Thumb

  

Here are all the winners:

Guru Award  WPF Technical Guru - June 2013  

Gold Award Winner

 

Gaurav Khanna Set Brush for ScrollViewer Thumb Peter Laker: "Good to know if you're not adept at Blend" Ed Price: "Great formatting on the code blocks!"

Silver Award Winner

 

XAML guy WPF: How to manage available/selected lists. Simple examples. MVVM and Code behind Ed Price: "It's beautiful. A work of art! From the TOC, to the image at the top, the breakdown of sections, the code snippets, and all the way down. It's easy to read and easy to follow. Great job!" Peter Laker: "A common problem, and a tidy solution :)"

Bronze Award Winner

 

Magnus (MM8) Event handling in an MVVM WPF application Peter Laker: "Nice event/command primer, lots of detail" Ed Price: "Good formatting on the code, and the image helps you visualize it! Good article!"

 

We had a few people come out to compete! Thanks to Guarav, XAML guy, and Magnus! You can find all 5 of their contributions here.

 

 

Here's an excerpt from the article:

 

 

In WPF/Silverlight ScrollViewer and ScrollBar control doesn't have any property to change color of Thumb dynamically from XAML by setting property. We have to edit the Style of ScrollBar and set the Brush for it according to our requirement. Based on requirement of one of the user on MSDN Forum I decided to create a Custom ScrollViewer which has a property to set Brush for Thumb.

PublicClass CustomScrollViewer

InheritsScrollViewer

SharedSub New ``()

DefaultStyleKeyProperty.OverrideMetadata(``GetType`` (CustomScrollViewer), ``New FrameworkPropertyMetadata( ``GetType``(CustomScrollViewer)))

EndSub

PublicProperty ScrollBarThumbBrush ``AsBrush

Get

ReturnGetValue(ScrollBarThumbBrushProperty)

EndGet

Set``(``ByVal value ``AsBrush)

SetValue(ScrollBarThumbBrushProperty, value)

EndSet

EndProperty

PublicShared ReadOnly ScrollBarThumbBrushProperty ``AsDependencyProperty = DependencyProperty.Register(``"ScrollBarThumbBrush"`` , ``GetType`` (Brush), ``GetType`` (CustomScrollBar), ``New PropertyMetadata(Brushes.Gray))

EndClass

 

 

 

==================

 

Read the rest here:

Set Brush for ScrollViewer Thumb 

 

Thanks to Khanna Gaurav for your great contribution to the TechNet Guru contest! You can read about all the June winners here: TechNet Guru Award Winners - June 2013

 

Also, for the August Guru competition, see TechNet Guru Contributions - August 2013. The judges are going through the July entries now. 

   

Are you a Wiki Ninja? https://technet.com/wiki

    - User Ed