Silverlight – Stop list box on the highlight display

I have a silverlight list box, and I want to remove the color change highlighting that occurs when the user selects an item in the list box.

By default , When selecting an item, the light blue of the item will be highlighted.

How to prevent this from happening?

As a side question, how can I customize this any color of any color?

Thank you.

You can customize the existing controls of the ListBox item Template to do this. The easy way is to start Expression Blend, right-click on ListBoxItem, go to Edit Control Parts (template), then select Edit a Copy…then customize fillColor and fillColor2 rectangle fill colors as needed.

The following Xaml sets the hover color of the ListBoxItem to transparent, and the selected color is green, but you can customize this color according to your needs:

  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
xmlns:x="http://schemas .microsoft.com/winfx/2006/xaml"
xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows"
Width="400" Height="300" Background= "#FF000000">








fillColor Rectangle specifies the color used when the user mouses over the ListBoxItem. In the above code, I set it to Transparent, When you hover over the ListBoxItem, no color will appear.

fillColor2 specifies the color to be used when the ListBoxItem is selected. In the above code, I specified #FF00FF00, so when the ListBoxItem When selected, the color will turn green.

In your case, you can set the “fill” property of the fillColor2 Rectangle to “transparent” to simulate no color when the user selects the item.

p>

I have a silverlight list box, and I want to remove the color change highlighting that occurs when the user selects an item in the list box.

default In this case, when an item is selected, the light blue of the item will be highlighted.

How to prevent this from happening?

As a side question, how can I customize this any color of any color?

Thank you.

You can do this by customizing the existing control template of the ListBox project. The easy way is to start Expression Blend, right-click the ListBoxItem, go to Edit Control Parts (template), then select Edit a Copy…Then customize the fillColor and fillColor2 rectangle fill colors as needed.

The following Xaml will ListBoxItem The hovering color is set to transparent, and the selected color is green, but you can customize this color according to your needs:

 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"< br /> xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows"
Width="400" Height="300" Background="#FF000000">


< /UserControl.Resources>





fillColor Rect angle specifies the color used when the user mouses over the ListBoxItem. In the above code, I set it to Transparent, when you hover the mouse over the ListBoxItem, no color will appear.

< p>fillColor2 specifies the color to be used when the ListBoxItem is selected. In the above code, I specified #FF00FF00, so when the ListBoxItem is selected, the color will turn green.

In your case, You can set the “fill” property of the fillColor2 Rectangle to “transparent” to simulate no color when the user selects an item.

Leave a Comment

Your email address will not be published.