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

Commit 4779ac1

Browse files
Add missing control styles
1 parent ba9773f commit 4779ac1

File tree

2 files changed

+262
-0
lines changed

2 files changed

+262
-0
lines changed

src/GitHub.UI/Assets/Controls.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
mc:Ignorable="d">
77

88
<ResourceDictionary.MergedDictionaries>
9+
<ResourceDictionary Source="Controls/AutoCompleteBox.xaml" />
910
<ResourceDictionary Source="Controls/RoundedCheckBox.xaml" />
1011
<ResourceDictionary Source="Controls/FilterTextBox.xaml" />
1112
<ResourceDictionary Source="Controls/GitHubLinkButton.xaml" />
Lines changed: 261 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,261 @@
1+
<!--
2+
// (c) Copyright Microsoft Corporation.
3+
// This source is subject to the Microsoft Public License (Ms-PL).
4+
// Please see http://go.microsoft.com/fwlink/?LinkID=131993] for details.
5+
// All other rights reserved.
6+
-->
7+
8+
<ResourceDictionary
9+
xmlns:sys="clr-namespace:System;assembly=mscorlib"
10+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
11+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
12+
xmlns:ui="clr-namespace:GitHub.UI">
13+
14+
<!-- CommonValidationToolTipTemplate -->
15+
<ControlTemplate x:Key="CommonValidationToolTipTemplate" TargetType="ToolTip">
16+
<Grid x:Name="Root" Margin="5,0" RenderTransformOrigin="0,0" Opacity="0">
17+
<Grid.RenderTransform>
18+
<TranslateTransform x:Name="Translation" X="-25" />
19+
</Grid.RenderTransform>
20+
21+
<VisualStateManager.VisualStateGroups>
22+
<VisualStateGroup Name="OpenStates">
23+
<VisualStateGroup.Transitions>
24+
<VisualTransition GeneratedDuration="0" />
25+
<VisualTransition To="Open" GeneratedDuration="0:0:0.2">
26+
<Storyboard>
27+
<DoubleAnimation Storyboard.TargetName="Translation" Storyboard.TargetProperty="X" To="0" Duration="0:0:0.2" />
28+
<DoubleAnimation Storyboard.TargetName="Root" Storyboard.TargetProperty="Opacity" To="1" Duration="0:0:0.2" />
29+
</Storyboard>
30+
</VisualTransition>
31+
</VisualStateGroup.Transitions>
32+
<VisualState x:Name="Closed">
33+
<Storyboard>
34+
<DoubleAnimation Storyboard.TargetName="Root" Storyboard.TargetProperty="Opacity" To="0" Duration="0" />
35+
</Storyboard>
36+
</VisualState>
37+
<VisualState x:Name="Open">
38+
<Storyboard>
39+
<DoubleAnimation Storyboard.TargetName="Translation" Storyboard.TargetProperty="X" To="0" Duration="0" />
40+
<DoubleAnimation Storyboard.TargetName="Root" Storyboard.TargetProperty="Opacity" To="1" Duration="0" />
41+
</Storyboard>
42+
</VisualState>
43+
</VisualStateGroup>
44+
</VisualStateManager.VisualStateGroups>
45+
46+
<Border Margin="4,4,-4,-4" Background="#052A2E31" CornerRadius="5" />
47+
<Border Margin="3,3,-3,-3" Background="#152A2E31" CornerRadius="4" />
48+
<Border Margin="2,2,-2,-2" Background="#252A2E31" CornerRadius="3" />
49+
<Border Margin="1,1,-1,-1" Background="#352A2E31" CornerRadius="2" />
50+
51+
<Border Background="#FFDC000C" CornerRadius="2">
52+
<TextBlock
53+
Foreground="White"
54+
Margin="8,4,8,4"
55+
MaxWidth="250"
56+
TextWrapping="Wrap"
57+
Text="{Binding (Validation.Errors)[0].ErrorContent}" />
58+
</Border>
59+
</Grid>
60+
</ControlTemplate>
61+
62+
63+
<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="{StaticResource GHBoxBackgroundBrush}"/>
69+
<Setter Property="Foreground" Value="{StaticResource GHBoxTextBrush}"/>
70+
<Setter Property="BorderBrush" Value="Transparent"/>
71+
<Setter Property="BorderThickness" Value="0"/>
72+
<Setter Property="FocusVisualStyle" Value="{StaticResource 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="{StaticResource 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="{StaticResource GHBoxSelectedBackgroundBrush}"/>
92+
<Setter Property="Foreground" Value="{StaticResource 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="{StaticResource GHBoxActiveSelectionBackgroundBrush}"/>
100+
<Setter Property="Foreground" Value="{StaticResource 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>
109+
</Style>
110+
111+
112+
<!-- input:AutoCompleteBox -->
113+
<Style TargetType="ui:AutoCompleteBox">
114+
<Setter Property="IsTabStop" Value="False" />
115+
<Setter Property="Padding" Value="2" />
116+
<Setter Property="Background" Value="{StaticResource DefaultBackgroundBrush}" />
117+
<Setter Property="Foreground" Value="{StaticResource GHTextBrush}" />
118+
<Setter Property="MinWidth" Value="45" />
119+
<Setter Property="ItemContainerStyle" Value="{StaticResource AutoCompleteListItemContainerStyle}" />
120+
121+
<Setter Property="Template">
122+
<Setter.Value>
123+
<ControlTemplate TargetType="ui:AutoCompleteBox">
124+
<Grid Opacity="{TemplateBinding Opacity}">
125+
<ContentPresenter
126+
x:Name="Text"
127+
Content="{Binding InputElement.Control, RelativeSource={RelativeSource TemplatedParent}}"/>
128+
<Border
129+
x:Name="ValidationErrorElement"
130+
Visibility="Collapsed"
131+
BorderBrush="#FFDB000C"
132+
BorderThickness="1"
133+
CornerRadius="1">
134+
<ToolTipService.ToolTip>
135+
<ToolTip
136+
x:Name="validationTooltip"
137+
DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}}"
138+
Template="{StaticResource CommonValidationToolTipTemplate}"
139+
Placement="Right"
140+
PlacementTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}">
141+
<ToolTip.Triggers>
142+
<EventTrigger RoutedEvent="Canvas.Loaded">
143+
<BeginStoryboard>
144+
<Storyboard>
145+
<ObjectAnimationUsingKeyFrames
146+
Storyboard.TargetName="validationTooltip"
147+
Storyboard.TargetProperty="IsHitTestVisible">
148+
<DiscreteObjectKeyFrame KeyTime="0">
149+
<DiscreteObjectKeyFrame.Value>
150+
<sys:Boolean>true</sys:Boolean>
151+
</DiscreteObjectKeyFrame.Value>
152+
</DiscreteObjectKeyFrame>
153+
</ObjectAnimationUsingKeyFrames>
154+
</Storyboard>
155+
</BeginStoryboard>
156+
</EventTrigger>
157+
</ToolTip.Triggers>
158+
</ToolTip>
159+
</ToolTipService.ToolTip>
160+
<Grid
161+
Height="12"
162+
HorizontalAlignment="Right"
163+
Margin="1,-4,-4,0"
164+
VerticalAlignment="Top"
165+
Width="12"
166+
Background="Transparent">
167+
<Path Fill="#FFDC000C" Margin="1,3,0,0" Data="M 1,0 L6,0 A 2,2 90 0 1 8,2 L8,7 z" />
168+
<Path Fill="#ffffff" Margin="1,3,0,0" Data="M 0,0 L2,0 L 8,6 L8,8" />
169+
</Grid>
170+
</Border>
171+
<Popup x:Name="Popup" Placement="Custom">
172+
<Grid Opacity="{TemplateBinding Opacity}" Background="{TemplateBinding Background}">
173+
<Border
174+
x:Name="PopupBorder"
175+
HorizontalAlignment="Stretch"
176+
Opacity="0"
177+
BorderBrush="#B0B0B0"
178+
BorderThickness="1">
179+
<ListBox
180+
x:Name="Selector"
181+
ScrollViewer.HorizontalScrollBarVisibility="Auto"
182+
ScrollViewer.VerticalScrollBarVisibility="Auto"
183+
ItemContainerStyle="{TemplateBinding ItemContainerStyle}"
184+
Background="{TemplateBinding Background}"
185+
Foreground="{TemplateBinding Foreground}"
186+
BorderThickness="0"
187+
ItemTemplate="{TemplateBinding ItemTemplate}" />
188+
</Border>
189+
</Grid>
190+
</Popup>
191+
<VisualStateManager.VisualStateGroups>
192+
<VisualStateGroup x:Name="PopupStates">
193+
<VisualStateGroup.Transitions>
194+
<VisualTransition GeneratedDuration="0:0:0.1" To="PopupOpened" />
195+
<VisualTransition GeneratedDuration="0:0:0.2" To="PopupClosed" />
196+
</VisualStateGroup.Transitions>
197+
<VisualState x:Name="PopupOpened">
198+
<Storyboard>
199+
<DoubleAnimation
200+
Storyboard.TargetName="PopupBorder"
201+
Storyboard.TargetProperty="Opacity"
202+
To="1.0"
203+
Duration="0:0:0.1" />
204+
</Storyboard>
205+
</VisualState>
206+
<VisualState x:Name="PopupClosed">
207+
<Storyboard>
208+
<DoubleAnimation
209+
Storyboard.TargetName="PopupBorder"
210+
Storyboard.TargetProperty="Opacity"
211+
To="0"
212+
Duration="0:0:0.2" />
213+
</Storyboard>
214+
</VisualState>
215+
</VisualStateGroup>
216+
<VisualStateGroup x:Name="ValidationStates">
217+
<VisualState x:Name="Valid" />
218+
<VisualState x:Name="InvalidUnfocused">
219+
<Storyboard>
220+
<ObjectAnimationUsingKeyFrames
221+
Storyboard.TargetName="ValidationErrorElement"
222+
Storyboard.TargetProperty="Visibility">
223+
<DiscreteObjectKeyFrame KeyTime="0">
224+
<DiscreteObjectKeyFrame.Value>
225+
<Visibility>Visible</Visibility>
226+
</DiscreteObjectKeyFrame.Value>
227+
</DiscreteObjectKeyFrame>
228+
</ObjectAnimationUsingKeyFrames>
229+
</Storyboard>
230+
</VisualState>
231+
<VisualState x:Name="InvalidFocused">
232+
<Storyboard>
233+
<ObjectAnimationUsingKeyFrames
234+
Storyboard.TargetName="ValidationErrorElement"
235+
Storyboard.TargetProperty="Visibility">
236+
<DiscreteObjectKeyFrame KeyTime="0">
237+
<DiscreteObjectKeyFrame.Value>
238+
<Visibility>Visible</Visibility>
239+
</DiscreteObjectKeyFrame.Value>
240+
</DiscreteObjectKeyFrame>
241+
</ObjectAnimationUsingKeyFrames>
242+
<ObjectAnimationUsingKeyFrames
243+
Storyboard.TargetName="validationTooltip"
244+
Storyboard.TargetProperty="IsOpen">
245+
<DiscreteObjectKeyFrame KeyTime="0">
246+
<DiscreteObjectKeyFrame.Value>
247+
<sys:Boolean>True</sys:Boolean>
248+
</DiscreteObjectKeyFrame.Value>
249+
</DiscreteObjectKeyFrame>
250+
</ObjectAnimationUsingKeyFrames>
251+
</Storyboard>
252+
</VisualState>
253+
</VisualStateGroup>
254+
</VisualStateManager.VisualStateGroups>
255+
</Grid>
256+
</ControlTemplate>
257+
</Setter.Value>
258+
</Setter>
259+
</Style>
260+
261+
</ResourceDictionary>

0 commit comments

Comments
 (0)