Geeks With Blogs


Add to Google

Tim Hibbard CEO for EnGraph software
Using colors is a simple way make your application less boring. You can change the color of the selected and unselected item in a ListBox by using code like this:

<Style TargetType="ListBoxItem">
        <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="LightGreen"/>
        <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="LightBlue"/>

This style can be put in the resources of the ListBox to just affect that ListBox, or it can be put in resources of the Window and it will apply these styles to all ListBoxes in the window. You can also use the Application.Resources of App.xaml and all ListBoxes in your application will have the same look and feel.

Technorati Tags: ,,
Posted on Tuesday, November 11, 2008 4:41 PM .NET , WPF | Back to top

Comments on this post: WPF - Using SystemColors to add color to ListBox

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © Tim Hibbard | Powered by: