Register Login

 

Welcome to the Coach Factor blog. Here you will find all of our ideas on software development. Subscribe at  http://blog.nventive.net.

# Tuesday, October 21, 2008

When we were in Quebec city last week training a group of people on WPF, one of the trainees asked a question :

   How would I go and change the "presentation" of the scroll bar.

This questioned was asked during one of the labs and so we had time (10 minutes) to come up with a quick answer, here is the walkthrough that we presented:

  1. Subclass the ScrollBar control by deriving a new class from it, don't forget to add this code in the static constructor so that styles gets hooked up correctly :

       18             DefaultStyleKeyProperty.OverrideMetadata(typeof(MyScrollBar),

       19                 new FrameworkPropertyMetadata(typeof(MyScrollBar)));

  2. Load up Reflector and locate the the PresentationFramwork.Aero.dll assembly in the GAC. This assembly contains WPF resource dictionaries that WPF merges into the application scope when a WPF application starts. WPF loads the correct dll "theme" file according to the OS that is running.
  3. Install the BamlViewer addin for Reflector because the DLL doesn't contain readable XAML. It is stored by the compiler in a binary format in order to optimize loading and storage of these massive XML files.
  4. Locate the section in the converted XAML that pertains to the ScrollBar control, copy that into your own resource section, rename a few things to "MyScrollBar" and voilĂ , a custom scrollbar.

This is the 1000 feet view on how to do skinning, and will require a lot more work when creating a custom style that works correctly (handling commands, events, triggers...).

It was a mere introduction to demonstrate the simplicity of the model that WPF uses to "present" controls.

Tuesday, October 21, 2008 8:20:53 PM (Eastern Standard Time, UTC-05:00)  #    Comments [1] -
.net - WPF
Thursday, October 23, 2008 4:50:24 AM (Eastern Standard Time, UTC-05:00)
At www.xamltemplates.net you have WPF Themes, and they give a template for free and in that you can see a scrollbar skined.
Comments are closed.
Search
Archive
<September 2010>
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
262728293012
3456789
Statistics
Total Posts: 98
This Year: 28
This Month: 1
This Week: 1
Comments: 17
Sign In