8000 Merge pull request #2292 from github/jcansdale/autocompletebox-theme · github/VisualStudio@84c4dd1 · GitHub
[go: up one dir, main page]

Skip to content
8000
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 84c4dd1

Browse files
Merge pull request #2292 from github/jcansdale/autocompletebox-theme
Theme the auto complete box
2 parents 3d539c8 + 28fc2f1 commit 84c4dd1

File tree

2 files changed

+43
-52
lines changed

2 files changed

+43
-52
lines changed

src/GitHub.UI/Assets/Controls/AutoCompleteBox.xaml

Lines changed: 41 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
xmlns:sys="clr-namespace:System;assembly=mscorlib"
1010
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
1111
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
12+
xmlns:vs="clr-namespace:Microsoft.VisualStudio.PlatformUI;assembly=Microsoft.VisualStudio.Shell.14.0"
1213
xmlns:ui="clr-namespace:GitHub.UI">
1314

1415
<!-- CommonValidationToolTipTemplate -->
@@ -59,62 +60,51 @@
5960
</Grid>
6061
</ControlTemplate>
6162

62-
63+
<ControlTemplate x:Key="ListViewItemControlTemplate" TargetType="{x:Type ListBoxItem}">
64+
<Border BorderBrush="{TemplateBinding BorderBrush}"
65+
BorderThickness="{TemplateBinding BorderThickness}"
66+
Background="{TemplateBinding Background}"
67+
SnapsToDevicePixels="True"
68+
Padding="{TemplateBinding Padding}">
69+
<ContentPresenter Content="{TemplateBinding Content}"
70+
ContentTemplate="{TemplateBinding ContentTemplate}"
71+
ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}" />
72+
</Border>
73+
</ControlTemplate>
74+
6375
<Style x:Key="AutoCompleteListItemContainerStyle" TargetType="{x:Type ListBoxItem}">
64-
<Setter Property="SnapsToDevicePixels" Value="True"/>
65-
<Setter Property="Padding" Value="5,0,10,0"/>
66-
<Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
67-
<Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
68-
<Setter Property="Background" Value="{DynamicResource GHBoxBackgroundBrush}"/>
69-
<Setter Property="Foreground" Value="{DynamicResource GHBoxTextBrush}"/>
70-
<Setter Property="BorderBrush" Value="Transparent"/>
71-
<Setter Property="BorderThickness" Value="0"/>
72-
<Setter Property="FocusVisualStyle" Value="{DynamicResource NoMarginFocusVisual}"/>
73-
<Setter Property="Template">
74-
<Setter.Value>
75-
<ControlTemplate TargetType="{x:Type ListBoxItem}">
76-
<Border x:Name="Bd" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true">
77-
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
78-
</Border>
79-
<ControlTemplate.Triggers>
80-
<MultiTrigger>
81-
<MultiTrigger.Conditions>
82-
<Condition Property="IsMouseOver" Value="True"/>
83-
</MultiTrigger.Conditions>
84-
<Setter Property="BorderBrush" TargetName="Bd" Value="{DynamicResource GHBoxHoverBackgroundBrush}"/>
85-
</MultiTrigger>
86-
<MultiTrigger>
87-
<MultiTrigger.Conditions>
88-
<Condition Property="Selector.IsSelectionActive" Value="False"/>
89-
<Condition Property="IsSelected" Value="True"/>
90-
</MultiTrigger.Conditions>
91-
<Setter Property="Background" Value="{DynamicResource GHBoxSelectedBackgroundBrush}"/>
92-
<Setter Property="Foreground" Value="{DynamicResource GHBoxSelectedTextBrush}"/>
93-
</MultiTrigger>
94-
<MultiTrigger>
95-
<MultiTrigger.Conditions>
96-
<Condition Property="Selector.IsSelectionActive" Value="True"/>
97-
<Condition Property="IsSelected" Value="True"/>
98-
</MultiTrigger.Conditions>
99-
<Setter Property="Background" Value="{DynamicResource GHBoxActiveSelectionBackgroundBrush}"/>
100-
<Setter Property="Foreground" Value="{DynamicResource GHBoxActiveSelectionTextBrush}"/>
101-
</MultiTrigger>
102-
<Trigger Property="IsEnabled" Value="False">
103-
<Setter Property="Opacity" TargetName="Bd" Value="0.3"/>
104-
</Trigger>
105-
</ControlTemplate.Triggers>
106-
</ControlTemplate>
107-
</Setter.Value>
108-
</Setter>
76+
<Setter Property="BorderThickness" Value="0" />
77+
<Setter Property="Padding" Value="5,3,3,3" />
78+
<Setter Property="Template" Value="{StaticResource ListViewItemControlTemplate}" />
79+
<Style.Triggers>
80+
<Trigger Property="IsMouseOver" Value="True">
81+
<Setter Property="Background" Value="{DynamicResource {x:Static vs:ThemedDialogColors.ListItemMouseOverBrushKey}}" />
82+
<Setter Property="Foreground" Value="{DynamicResource {x:Static vs:ThemedDialogColors.ListItemMouseOverTextBrushKey}}" />
83+
</Trigger>
84+
<Trigger Property="IsSelected" Value="true">
85+
<Setter Property="Background" Value="{DynamicResource {x:Static vs:ThemedDialogColors.SelectedItemInactiveBrushKey}}" />
86+
<Setter Property="Foreground" Value="{DynamicResource {x:Static vs:ThemedDialogColors.SelectedItemInactiveTextBrushKey}}" />
87+
</Trigger>
88+
<MultiTrigger>
89+
<MultiTrigger.Conditions>
90+
<Condition Property="IsSelected" Value="True" />
91+
<Condition Property="Selector.IsSelectionActive" Value="True" />
92+
</MultiTrigger.Conditions>
93+
<Setter Property="Background" Value="{DynamicResource {x:Static vs:ThemedDialogColors.SelectedItemActiveBrushKey}}" />
94+
<Setter Property="Foreground" Value="{DynamicResource {x:Static vs:ThemedDialogColors.SelectedItemActiveTextBrushKey}}" />
95+
</MultiTrigger>
96+
<Trigger Property="IsEnabled" Value="False">
97+
<Setter Property="Foreground" Value="{DynamicResource {x:Static vs:ThemedDialogColors.ListItemDisabledTextBrushKey}}" />
98+
</Trigger>
99+
</Style.Triggers>
109100
</Style>
110-
111101

112102
<!-- input:AutoCompleteBox -->
113103
<Style TargetType="ui:AutoCompleteBox">
114104
<Setter Property="IsTabStop" Value="False" />
115105
<Setter Property="Padding" Value="2" />
116-
<Setter Property="Background" Value="{DynamicResource DefaultBackgroundBrush}" />
117-
<Setter Property="Foreground" Value="{DynamicResource GHTextBrush}" />
106+
<Setter Property="Background" Value="{DynamicResource {x:Static vs:ThemedDialogColors.WindowPanelBrushKey}}" />
107+
<Setter Property="Foreground" Value="{DynamicResource {x:Static vs:ThemedDialogColors.WindowPanelTextBrushKey}}" />
118108
<Setter Property="MinWidth" Value="45" />
119109
<Setter Property="ItemContainerStyle" Value="{StaticResource AutoCompleteListItemContainerStyle}" />
120110

@@ -125,6 +115,7 @@
125115
<ContentPresenter
126116
x:Name="Text"
127117
Content="{Binding InputElement.Control, RelativeSource={RelativeSource TemplatedParent}}"/>
118+
<!-- TODO: What should we use for validation BorderBrush? -->
128119
<Border
129120
x:Name="ValidationErrorElement"
130121
Visibility="Collapsed"
@@ -174,7 +165,7 @@
174165
x:Name="PopupBorder"
175166
HorizontalAlignment="Stretch"
176167
Opacity="0"
177-
BorderBrush="#B0B0B0"
168+
BorderBrush="{DynamicResource {x:Static vs:CommonControlsColors.TextBoxBorderFocusedBrushKey}}"
178169
BorderThickness="1">
179170
<ListBox
180171
x:Name="Selector"

src/GitHub.UI/Views/AutoCompleteSuggestionView.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
<RectangleGeometry Rect="0,0,24,24" RadiusX="2" RadiusY="2" />
2121
</Image.Clip>
2222
</Image>
23-
<TextBlock x:Nam 5B7F e="suggestionText" Style="{DynamicResource GitHubTextBlock}" VerticalAlignment="Center">
24-
<Run x:Name="name" Foreground="{DynamicResource GHTextBrush}" Text="Name" /> <Run x:Name="description" Foreground="{DynamicResource GHTextSecondaryBrush}" Text="Description" />
23+
<TextBlock x:Name="suggestionText" VerticalAlignment="Center">
24+
<Run x:Name="name" Text="Name" /> <Run x:Name="description" Text="Description" />
2525
</TextBlock>
2626
</StackPanel>
2727
</UserControl>

0 commit comments

Comments
 (0)
0