Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

how to change listbox item font color when selected ?

$
0
0

Dear all,

I have the following style for my list box. When items gets selected, the background border cames white, but I want to change also the font colors of items to be blue.

Could not reach that proper place to be affected :

<Style x:Key="ListBoxItemStyle1" TargetType="{x:Type ListBoxItem}"
			BasedOn="{StaticResource ControlBaseStyle}"><Setter Property="Background" 
				Value="#FF002F6B"/><Setter Property="Foreground" 
				Value="White"/><Setter Property="BorderThickness" 
				Value="0"/><Setter Property="Padding" 
				Value="10"/><Setter Property="HorizontalContentAlignment"
				Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type ItemsControl}}}" /><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="{x:Type s:SurfaceListBoxItem}"><Grid   x:Name="Grid"
							Background="{StaticResource ControlHitAreaBrush}"
							SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"><Border  x:Name="ButtonBody" CornerRadius="0,10,0,10"
								BorderThickness="{TemplateBinding BorderThickness}"
								Background="{TemplateBinding Background}"
								BorderBrush="{TemplateBinding BorderBrush}"
								SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/><ContentPresenter   x:Name="Content"										
								Margin="{TemplateBinding Padding}"
								HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"                               					   
								VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
								SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/></Grid><ControlTemplate.Triggers><Trigger Property="IsSelected"		  
								Value="True"><Setter Property="Background" 
									TargetName="ButtonBody" 
									Value="White"/></Trigger><Trigger Property="IsPressed"
								Value="True"/><MultiTrigger><MultiTrigger.Conditions><Condition Property="IsEnabled"
										Value="False" /><Condition Property="IsSelected"
										Value="True" /></MultiTrigger.Conditions><Setter Property="Background"
									Value="{DynamicResource {x:Static s:SurfaceColors.ListBoxItemSelectionBackgroundDisabledBrushKey}}"
									TargetName="ButtonBody"/><Setter Property="Foreground"
									Value="{DynamicResource {x:Static s:SurfaceColors.ListBoxItemForegroundDisabledBrushKey}}"/><Setter Property="Opacity"
									TargetName="Content"
									Value="0.6"/></MultiTrigger><MultiTrigger><MultiTrigger.Conditions><Condition  Property="IsEnabled"
										Value="False" /><Condition Property="IsSelected"
										Value="False" /></MultiTrigger.Conditions><Setter Property="Background"
									Value="{DynamicResource {x:Static s:SurfaceColors.ListBoxItemBackgroundDisabledBrushKey}}"
									TargetName="ButtonBody"/><Setter Property="Foreground"
									Value="{DynamicResource {x:Static s:SurfaceColors.ListBoxItemForegroundDisabledBrushKey}}"/><Setter Property="Opacity"
									TargetName="Content"
									Value="0.33"/></MultiTrigger></ControlTemplate.Triggers></ControlTemplate></Setter.Value></Setter></Style>

Thanks for help

regards

serge


Your knowledge is enhanced by that of others.


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>