mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-06-07 09:28:03 +08:00
Fix color of selected item and mouse item
This is part of .net 4.5 fix, check #393 to see more
This commit is contained in:
parent
74fb470647
commit
4d25d505e0
@ -7,44 +7,82 @@
|
|||||||
xmlns:converters="clr-namespace:Wox.Converters"
|
xmlns:converters="clr-namespace:Wox.Converters"
|
||||||
mc:Ignorable="d" d:DesignWidth="100" d:DesignHeight="100">
|
mc:Ignorable="d" d:DesignWidth="100" d:DesignHeight="100">
|
||||||
|
|
||||||
<ListBox x:Name="lbResults" MaxHeight="{Binding ElementName=Results, Path=MaxResultsToShow}" HorizontalContentAlignment="Stretch" PreviewMouseDown="LbResults_OnPreviewMouseDown" Style="{DynamicResource BaseListboxStyle}" SelectionChanged ="lbResults_SelectionChanged" Focusable="False" KeyboardNavigation.DirectionalNavigation="Cycle" SelectionMode="Single" VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Standard">
|
<ListBox x:Name="lbResults" MaxHeight="{Binding ElementName=Results, Path=MaxResultsToShow}"
|
||||||
<ListBox.Resources>
|
HorizontalContentAlignment="Stretch" PreviewMouseDown="LbResults_OnPreviewMouseDown"
|
||||||
<!--SelectedItem with focus-->
|
Style="{DynamicResource BaseListboxStyle}" SelectionChanged="lbResults_SelectionChanged" Focusable="False"
|
||||||
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="{DynamicResource ItemSelectedBackgroundColor}"/>
|
KeyboardNavigation.DirectionalNavigation="Cycle" SelectionMode="Single"
|
||||||
<!--SelectedItem without focus-->
|
VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Standard">
|
||||||
<SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="{DynamicResource ItemSelectedBackgroundColor}"/>
|
|
||||||
</ListBox.Resources>
|
|
||||||
<ListBox.ItemTemplate>
|
<ListBox.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<!-- a result item height is 50 including margin -->
|
<!-- a result item height is 50 including margin -->
|
||||||
<Grid HorizontalAlignment="Stretch" Height="40" VerticalAlignment="Stretch" Margin="5" Cursor="Hand">
|
<Grid HorizontalAlignment="Stretch" Height="40" VerticalAlignment="Stretch" Margin="5"
|
||||||
|
Cursor="Hand">
|
||||||
<Grid.Resources>
|
<Grid.Resources>
|
||||||
<converters:ImagePathConverter x:Key="ImageConverter" />
|
<converters:ImagePathConverter x:Key="ImageConverter" />
|
||||||
</Grid.Resources>
|
</Grid.Resources>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="32"></ColumnDefinition>
|
<ColumnDefinition Width="32" />
|
||||||
<ColumnDefinition/>
|
<ColumnDefinition />
|
||||||
<ColumnDefinition Width="0" />
|
<ColumnDefinition Width="0" />
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<Image x:Name="imgIco" Width="32" Height="32" HorizontalAlignment="Left" Source="{Binding FullIcoPath,Converter={StaticResource ImageConverter},IsAsync=True}" >
|
<Image x:Name="imgIco" Width="32" Height="32" HorizontalAlignment="Left"
|
||||||
</Image>
|
Source="{Binding FullIcoPath,Converter={StaticResource ImageConverter},IsAsync=True}" />
|
||||||
<Grid Margin="5 0 5 0" Grid.Column="1" HorizontalAlignment="Stretch">
|
<Grid Margin="5 0 5 0" Grid.Column="1" HorizontalAlignment="Stretch">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition></RowDefinition>
|
<RowDefinition />
|
||||||
<RowDefinition Height="Auto" x:Name="SubTitleRowDefinition"></RowDefinition>
|
<RowDefinition Height="Auto" x:Name="SubTitleRowDefinition" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<TextBlock Style="{DynamicResource ItemTitleStyle}" DockPanel.Dock="Left" VerticalAlignment="Center" ToolTip="{Binding Title}" x:Name="tbTitle" Text="{Binding Title}"></TextBlock>
|
<TextBlock Style="{DynamicResource ItemTitleStyle}" DockPanel.Dock="Left"
|
||||||
<TextBlock Style="{DynamicResource ItemSubTitleStyle}" ToolTip="{Binding SubTitle}" Visibility="{Binding SubTitle, Converter={converters:StringNullOrEmptyToVisibilityConverter}}" Grid.Row="1" x:Name="tbSubTitle" Text="{Binding SubTitle}"></TextBlock>
|
VerticalAlignment="Center" ToolTip="{Binding Title}" x:Name="tbTitle"
|
||||||
|
Text="{Binding Title}" />
|
||||||
|
<TextBlock Style="{DynamicResource ItemSubTitleStyle}" ToolTip="{Binding SubTitle}"
|
||||||
|
Visibility="{Binding SubTitle, Converter={converters:StringNullOrEmptyToVisibilityConverter}}"
|
||||||
|
Grid.Row="1" x:Name="tbSubTitle" Text="{Binding SubTitle}" />
|
||||||
</Grid>
|
</Grid>
|
||||||
<TextBlock Grid.Column="2" x:Name="tbItemNumber" Style="{DynamicResource ItemNumberStyle}" Text="9"></TextBlock>
|
<TextBlock Grid.Column="2" x:Name="tbItemNumber" Style="{DynamicResource ItemNumberStyle}" Text="9"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
<DataTemplate.Triggers>
|
<DataTemplate.Triggers>
|
||||||
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}}, Path=IsSelected}" Value="True">
|
<DataTrigger
|
||||||
<Setter TargetName="tbTitle" Property="Style" Value="{DynamicResource ItemTitleSelectedStyle}"/>
|
Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}}, Path=IsSelected}"
|
||||||
<Setter TargetName="tbSubTitle" Property="Style" Value="{DynamicResource ItemSubTitleSelectedStyle}"/>
|
Value="True">
|
||||||
|
<Setter TargetName="tbTitle" Property="Style" Value="{DynamicResource ItemTitleSelectedStyle}" />
|
||||||
|
<Setter TargetName="tbSubTitle" Property="Style"
|
||||||
|
Value="{DynamicResource ItemSubTitleSelectedStyle}" />
|
||||||
</DataTrigger>
|
</DataTrigger>
|
||||||
</DataTemplate.Triggers>
|
</DataTemplate.Triggers>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ListBox.ItemTemplate>
|
</ListBox.ItemTemplate>
|
||||||
|
<!--http://stackoverflow.com/questions/16819577/setting-background-color-or-wpf-4-0-listbox-windows-8/#16820062-->
|
||||||
|
<ListBox.ItemContainerStyle>
|
||||||
|
<Style TargetType="{x:Type ListBoxItem}">
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="{x:Type ListBoxItem}">
|
||||||
|
<Border x:Name="Bd"
|
||||||
|
Background="{TemplateBinding Background}"
|
||||||
|
BorderBrush="{TemplateBinding BorderBrush}"
|
||||||
|
BorderThickness="{TemplateBinding BorderThickness}"
|
||||||
|
Padding="{TemplateBinding Padding}"
|
||||||
|
SnapsToDevicePixels="True">
|
||||||
|
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||||
|
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||||
|
Content="{TemplateBinding Content}"
|
||||||
|
ContentStringFormat="{TemplateBinding ContentStringFormat}"
|
||||||
|
ContentTemplate="{TemplateBinding ContentTemplate}"
|
||||||
|
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
|
||||||
|
</Border>
|
||||||
|
<ControlTemplate.Triggers>
|
||||||
|
<Trigger Property="IsSelected" Value="True">
|
||||||
|
<Setter TargetName="Bd" Property="Background"
|
||||||
|
Value="{DynamicResource ItemSelectedBackgroundColor}" />
|
||||||
|
<Setter TargetName="Bd" Property="BorderBrush"
|
||||||
|
Value="{DynamicResource ItemSelectedBackgroundColor}" />
|
||||||
|
</Trigger>
|
||||||
|
</ControlTemplate.Triggers>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
</ListBox.ItemContainerStyle>
|
||||||
</ListBox>
|
</ListBox>
|
||||||
</UserControl>
|
</UserControl>
|
@ -46,7 +46,7 @@
|
|||||||
<Style x:Key="ItemSubTitleSelectedStyle" BasedOn="{StaticResource BaseItemSubTitleSelectedStyle}" TargetType="{x:Type TextBlock}" >
|
<Style x:Key="ItemSubTitleSelectedStyle" BasedOn="{StaticResource BaseItemSubTitleSelectedStyle}" TargetType="{x:Type TextBlock}" >
|
||||||
<Setter Property="Foreground" Value="#FFFFFFFF"/>
|
<Setter Property="Foreground" Value="#FFFFFFFF"/>
|
||||||
</Style>
|
</Style>
|
||||||
<Color x:Key="ItemSelectedBackgroundColor">#356ef3</Color>
|
<SolidColorBrush x:Key="ItemSelectedBackgroundColor">#356ef3</SolidColorBrush>
|
||||||
|
|
||||||
<!-- button style in the middle of the scrollbar -->
|
<!-- button style in the middle of the scrollbar -->
|
||||||
<Style x:Key="ThumbStyle" BasedOn="{StaticResource BaseThumbStyle}" TargetType="{x:Type Thumb}">
|
<Style x:Key="ThumbStyle" BasedOn="{StaticResource BaseThumbStyle}" TargetType="{x:Type Thumb}">
|
||||||
|
@ -46,7 +46,7 @@
|
|||||||
<Style x:Key="ItemSubTitleSelectedStyle" BasedOn="{StaticResource BaseItemSubTitleSelectedStyle}" TargetType="{x:Type TextBlock}" >
|
<Style x:Key="ItemSubTitleSelectedStyle" BasedOn="{StaticResource BaseItemSubTitleSelectedStyle}" TargetType="{x:Type TextBlock}" >
|
||||||
<Setter Property="Foreground" Value="#FFFFFFFF"/>
|
<Setter Property="Foreground" Value="#FFFFFFFF"/>
|
||||||
</Style>
|
</Style>
|
||||||
<Color x:Key="ItemSelectedBackgroundColor">#356ef3</Color>
|
<SolidColorBrush x:Key="ItemSelectedBackgroundColor">#356ef3</SolidColorBrush>
|
||||||
|
|
||||||
<!-- button style in the middle of the scrollbar -->
|
<!-- button style in the middle of the scrollbar -->
|
||||||
<Style x:Key="ThumbStyle" BasedOn="{StaticResource BaseThumbStyle}" TargetType="{x:Type Thumb}">
|
<Style x:Key="ThumbStyle" BasedOn="{StaticResource BaseThumbStyle}" TargetType="{x:Type Thumb}">
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
</Style>
|
</Style>
|
||||||
<Style x:Key="ItemSubTitleSelectedStyle" BasedOn="{StaticResource BaseItemSubTitleSelectedStyle}" TargetType="{x:Type TextBlock}" >
|
<Style x:Key="ItemSubTitleSelectedStyle" BasedOn="{StaticResource BaseItemSubTitleSelectedStyle}" TargetType="{x:Type TextBlock}" >
|
||||||
</Style>
|
</Style>
|
||||||
<Color x:Key="ItemSelectedBackgroundColor">#4F6180</Color>
|
<SolidColorBrush x:Key="ItemSelectedBackgroundColor">#4F6180</SolidColorBrush>
|
||||||
|
|
||||||
<!-- button style in the middle of the scrollbar -->
|
<!-- button style in the middle of the scrollbar -->
|
||||||
<Style x:Key="ThumbStyle" BasedOn="{StaticResource BaseThumbStyle}" TargetType="{x:Type Thumb}">
|
<Style x:Key="ThumbStyle" BasedOn="{StaticResource BaseThumbStyle}" TargetType="{x:Type Thumb}">
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
<Style x:Key="ItemSubTitleSelectedStyle" BasedOn="{StaticResource BaseItemSubTitleSelectedStyle}" TargetType="{x:Type TextBlock}">
|
<Style x:Key="ItemSubTitleSelectedStyle" BasedOn="{StaticResource BaseItemSubTitleSelectedStyle}" TargetType="{x:Type TextBlock}">
|
||||||
<Setter Property="Foreground" Value="#ffffff" />
|
<Setter Property="Foreground" Value="#ffffff" />
|
||||||
</Style>
|
</Style>
|
||||||
<Color x:Key="ItemSelectedBackgroundColor">#00AAF6</Color>
|
<SolidColorBrush x:Key="ItemSelectedBackgroundColor">#00AAF6</SolidColorBrush>
|
||||||
<Style x:Key="ThumbStyle" BasedOn="{StaticResource BaseThumbStyle}" TargetType="{x:Type Thumb}">
|
<Style x:Key="ThumbStyle" BasedOn="{StaticResource BaseThumbStyle}" TargetType="{x:Type Thumb}">
|
||||||
<Setter Property="Template">
|
<Setter Property="Template">
|
||||||
<Setter.Value>
|
<Setter.Value>
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
<Style x:Key="ItemSubTitleSelectedStyle" BasedOn="{StaticResource BaseItemSubTitleSelectedStyle}" TargetType="{x:Type TextBlock}">
|
<Style x:Key="ItemSubTitleSelectedStyle" BasedOn="{StaticResource BaseItemSubTitleSelectedStyle}" TargetType="{x:Type TextBlock}">
|
||||||
<Setter Property="Foreground" Value="#F6F6FF" />
|
<Setter Property="Foreground" Value="#F6F6FF" />
|
||||||
</Style>
|
</Style>
|
||||||
<Color x:Key="ItemSelectedBackgroundColor">#3875D7</Color>
|
<SolidColorBrush x:Key="ItemSelectedBackgroundColor">#3875D7</SolidColorBrush>
|
||||||
|
|
||||||
<!-- button style in the middle of the scrollbar -->
|
<!-- button style in the middle of the scrollbar -->
|
||||||
<Style x:Key="ThumbStyle" BasedOn="{StaticResource BaseThumbStyle}" TargetType="{x:Type Thumb}">
|
<Style x:Key="ThumbStyle" BasedOn="{StaticResource BaseThumbStyle}" TargetType="{x:Type Thumb}">
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
<Style x:Key="ItemSubTitleSelectedStyle" BasedOn="{StaticResource BaseItemSubTitleSelectedStyle}" TargetType="{x:Type TextBlock}">
|
<Style x:Key="ItemSubTitleSelectedStyle" BasedOn="{StaticResource BaseItemSubTitleSelectedStyle}" TargetType="{x:Type TextBlock}">
|
||||||
<Setter Property="Foreground" Value="#c2c2c2" />
|
<Setter Property="Foreground" Value="#c2c2c2" />
|
||||||
</Style>
|
</Style>
|
||||||
<Color x:Key="ItemSelectedBackgroundColor">#006ac1</Color>
|
<SolidColorBrush x:Key="ItemSelectedBackgroundColor">#006ac1</SolidColorBrush>
|
||||||
<Style x:Key="ThumbStyle" BasedOn="{StaticResource BaseThumbStyle}" TargetType="{x:Type Thumb}">
|
<Style x:Key="ThumbStyle" BasedOn="{StaticResource BaseThumbStyle}" TargetType="{x:Type Thumb}">
|
||||||
</Style>
|
</Style>
|
||||||
<Style x:Key="ScrollBarStyle" BasedOn="{StaticResource BaseScrollBarStyle}" TargetType="{x:Type ScrollBar}">
|
<Style x:Key="ScrollBarStyle" BasedOn="{StaticResource BaseScrollBarStyle}" TargetType="{x:Type ScrollBar}">
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
<Style x:Key="ItemSubTitleSelectedStyle" BasedOn="{StaticResource BaseItemSubTitleSelectedStyle}" TargetType="{x:Type TextBlock}">
|
<Style x:Key="ItemSubTitleSelectedStyle" BasedOn="{StaticResource BaseItemSubTitleSelectedStyle}" TargetType="{x:Type TextBlock}">
|
||||||
<Setter Property="Foreground" Value="#c2c2c2" />
|
<Setter Property="Foreground" Value="#c2c2c2" />
|
||||||
</Style>
|
</Style>
|
||||||
<Color x:Key="ItemSelectedBackgroundColor">#cc1081</Color>
|
<SolidColorBrush x:Key="ItemSelectedBackgroundColor">#cc1081</SolidColorBrush>
|
||||||
<Style x:Key="ThumbStyle" BasedOn="{StaticResource BaseThumbStyle}" TargetType="{x:Type Thumb}"></Style>
|
<Style x:Key="ThumbStyle" BasedOn="{StaticResource BaseThumbStyle}" TargetType="{x:Type Thumb}"></Style>
|
||||||
<Style x:Key="ScrollBarStyle" BasedOn="{StaticResource BaseScrollBarStyle}" TargetType="{x:Type ScrollBar}"></Style>
|
<Style x:Key="ScrollBarStyle" BasedOn="{StaticResource BaseScrollBarStyle}" TargetType="{x:Type ScrollBar}"></Style>
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
Loading…
Reference in New Issue
Block a user