Tim Hibbard

Software Architect for EnGraph software
posts - 615, comments - 676, trackbacks - 469

My Links

News



Add to Google




Twitter












Tag Cloud

Article Categories

Archives

Post Categories

Image Galleries

EnGraph Blogs

Links

Other

Roll

WPF - Using SystemColors to add color to ListBox

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">
    <Style.Resources>
        <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="LightGreen"/>
        <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="LightBlue"/>
    </Style.Resources>
</Style>


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: ,,

Print | posted on Tuesday, November 11, 2008 4:41 PM | Filed Under [ .NET WPF ]

Feedback

No comments posted yet.
Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification:
 

Powered by: