1
- <ListBox
2
- x : Class =" Flow.Launcher.ResultListBox"
1
+ <ListBox x : Class =" Flow.Launcher.ResultListBox"
3
2
xmlns =" http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4
3
xmlns : x =" http://schemas.microsoft.com/winfx/2006/xaml"
5
4
xmlns : converter =" clr-namespace:Flow.Launcher.Converters"
31
30
mc : Ignorable =" d" >
32
31
<!-- IsSynchronizedWithCurrentItem: http://stackoverflow.com/a/7833798/2833083 -->
33
32
33
+ <ListBox .Resources>
34
+ <converter : IconRadiusConverter x : Key =" IconRadiusConverter" />
35
+ <converter : DiameterToCenterPointConverter x : Key =" DiameterToCenterPointConverter" />
36
+ </ListBox .Resources>
34
37
<ListBox .ItemTemplate>
35
38
<DataTemplate >
36
39
<Button HorizontalAlignment =" Stretch" >
40
43
</ControlTemplate >
41
44
</Button .Template>
42
45
<Button .Content>
43
- <Grid
44
- Margin =" 0"
46
+ <Grid Margin =" 0"
45
47
HorizontalAlignment =" Stretch"
46
48
VerticalAlignment =" Stretch"
47
49
Cursor =" Hand"
54
56
<Grid .ColumnDefinitions>
55
57
<ColumnDefinition Width =" 60" />
56
58
<ColumnDefinition Width =" 9*" />
57
- <ColumnDefinition Width =" Auto" MinWidth =" 8" />
59
+ <ColumnDefinition Width =" Auto"
60
+ MinWidth =" 8" />
58
61
</Grid .ColumnDefinitions>
59
- <StackPanel
60
- x : Name =" HotkeyArea"
62
+ <StackPanel x : Name =" HotkeyArea"
61
63
Grid.Column=" 2"
62
64
Margin =" 0,0,10,0"
63
65
VerticalAlignment =" Center"
64
66
Visibility =" {Binding ShowOpenResultHotkey}" >
65
- <TextBlock
66
- x : Name =" Hotkey"
67
+ <TextBlock x : Name =" Hotkey"
67
68
Margin =" 12,0,12,0"
68
69
Padding =" 0,0,0,0"
69
70
HorizontalAlignment =" Right"
70
71
VerticalAlignment =" Center"
71
72
Style =" {DynamicResource ItemHotkeyStyle}" >
72
73
<TextBlock .Visibility>
73
- <Binding Converter =" {StaticResource ResourceKey=OpenResultHotkeyVisibilityConverter}" RelativeSource =" {RelativeSource Mode=FindAncestor, AncestorType=ListBoxItem}" />
74
+ <Binding
75
+ Converter =" {StaticResource ResourceKey=OpenResultHotkeyVisibilityConverter}"
76
+ RelativeSource =" {RelativeSource Mode=FindAncestor, AncestorType=ListBoxItem}" />
74
77
</TextBlock .Visibility>
75
78
<TextBlock .Text>
76
79
<MultiBinding StringFormat =" {}{0}+{1}" >
77
80
<Binding Path =" OpenResultModifiers" />
78
- <Binding Converter =" {StaticResource ResourceKey=OrdinalConverter}" RelativeSource =" {RelativeSource Mode=FindAncestor, AncestorType=ListBoxItem}" />
81
+ <Binding Converter =" {StaticResource ResourceKey=OrdinalConverter}"
82
+ RelativeSource =" {RelativeSource Mode=FindAncestor, AncestorType=ListBoxItem}" />
79
83
</MultiBinding >
80
84
</TextBlock .Text>
81
85
</TextBlock >
87
91
<ColumnDefinition />
88
92
</Grid .ColumnDefinitions>
89
93
90
- <Border
91
- x : Name =" Bullet"
94
+ <Border x : Name =" Bullet"
92
95
Grid.Column=" 0"
93
96
Style =" {DynamicResource BulletStyle}" />
94
97
95
- <Border
96
- Grid.Column=" 1"
98
+ <Border Grid.Column=" 1"
97
99
Margin =" 9,0,0,0"
98
100
BorderBrush =" Transparent"
99
101
BorderThickness =" 1" >
100
- <Image
101
- x : Name =" ImageIcon"
102
- Width =" {Binding IconXY}"
103
- Height =" {Binding IconXY}"
102
+ <Image x : Name =" ImageIcon"
103
+ Style =" {DynamicResource ImageIconStyle}"
104
104
Margin =" 0,0,0,0"
105
105
HorizontalAlignment =" Center"
106
106
IsHitTestVisible =" False"
110
110
Visibility =" {Binding ShowIcon}" >
111
111
<Image .Clip>
112
112
<EllipseGeometry
113
- Center =" 16 16"
114
- RadiusX =" {Binding IconRadius}"
115
- RadiusY =" {Binding IconRadius}" />
113
+ Center =" {Binding ElementName=ImageIcon, Path=ActualWidth, Converter={StaticResource DiameterToCenterPointConverter}}" >
114
+ <EllipseGeometry .RadiusX>
115
+ <MultiBinding Converter =" {StaticResource IconRadiusConverter}" >
116
+ <Binding ElementName =" ImageIcon"
117
+ Path =" ActualWidth" />
118
+ <Binding Path =" Result.RoundedIcon" />
119
+ </MultiBinding >
120
+ </EllipseGeometry .RadiusX>
121
+ <EllipseGeometry .RadiusY>
122
+ <MultiBinding Converter =" {StaticResource IconRadiusConverter}" >
123
+ <Binding ElementName =" ImageIcon"
124
+ Path =" ActualWidth" />
125
+ <Binding Path =" Result.RoundedIcon" />
126
+ </MultiBinding >
127
+ </EllipseGeometry .RadiusY>
128
+ </EllipseGeometry >
116
129
</Image .Clip>
117
130
</Image >
118
131
</Border >
119
- <Border
120
- Grid.Column=" 1"
132
+ <Border Grid.Column=" 1"
121
133
Margin =" 9,0,0,0"
122
134
BorderBrush =" Transparent"
123
135
BorderThickness =" 0" >
124
- <TextBlock
125
- x : Name =" GlyphIcon"
136
+ <TextBlock x : Name =" GlyphIcon"
126
137
HorizontalAlignment =" Center"
127
138
VerticalAlignment =" Center"
128
139
FontFamily =" {Binding Glyph.FontFamily}"
132
143
</Border >
133
144
</Grid >
134
145
135
- <Grid
136
- Grid.Column=" 1"
146
+ <Grid Grid.Column=" 1"
137
147
Margin =" 6,0,10,0"
138
148
HorizontalAlignment =" Stretch"
139
149
VerticalAlignment =" Center" >
140
150
<Grid .RowDefinitions>
141
151
<RowDefinition Height =" Auto" />
142
- <RowDefinition x : Name =" SubTitleRowDefinition" Height =" Auto" />
152
+ <RowDefinition x : Name =" SubTitleRowDefinition"
153
+ Height =" Auto" />
143
154
</Grid .RowDefinitions>
144
- <ProgressBar
145
- x : Name =" progressbarResult"
155
+ <ProgressBar x : Name =" progressbarResult"
146
156
Grid.Row=" 0"
147
157
Foreground =" {Binding Result.ProgressBarColor}"
148
158
Value =" {Binding ResultProgress, Mode=OneWay}" >
149
159
<ProgressBar .Style>
150
- <Style BasedOn =" {StaticResource ProgressBarResult}" TargetType =" ProgressBar" >
151
- <Setter Property =" Visibility" Value =" Visible" />
160
+ <Style BasedOn =" {StaticResource ProgressBarResult}"
161
+ TargetType =" ProgressBar" >
162
+ <Setter Property =" Visibility"
163
+ Value =" Visible" />
152
164
<Style .Triggers>
153
- <DataTrigger Binding =" {Binding Result.ProgressBar}" Value =" {x:Null}" >
154
- <Setter Property =" Visibility" Value =" Collapsed" />
165
+ <DataTrigger Binding =" {Binding Result.ProgressBar}"
166
+ Value =" {x:Null}" >
167
+ <Setter Property =" Visibility"
168
+ Value =" Collapsed" />
155
169
</DataTrigger >
156
170
</Style .Triggers>
157
171
</Style >
158
172
</ProgressBar .Style>
159
173
</ProgressBar >
160
- <TextBlock
161
- x : Name =" Title"
174
+ <TextBlock x : Name =" Title"
162
175
Grid.Row=" 0"
163
176
VerticalAlignment =" Center"
164
177
DockPanel.Dock=" Left"
175
188
</MultiBinding >
176
189
</vm : ResultsViewModel .FormattedText>
177
190
</TextBlock >
178
- <TextBlock
179
- x : Name =" SubTitle"
191
+ <TextBlock x : Name =" SubTitle"
180
192
Grid.Row=" 1"
181
193
IsEnabled =" False"
182
194
Style =" {DynamicResource ItemSubTitleStyle}"
191
203
</Button >
192
204
<!-- a result item height is 52 including margin -->
193
205
<DataTemplate .Triggers>
194
- <DataTrigger Binding =" {Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}}, Path=IsSelected}" Value =" True" >
195
- <Setter TargetName =" Bullet" Property =" Style" Value =" {DynamicResource ItemBulletSelectedStyle}" />
196
- <Setter TargetName =" Title" Property =" Style" Value =" {DynamicResource ItemTitleSelectedStyle}" />
197
- <Setter TargetName =" SubTitle" Property =" Style" Value =" {DynamicResource ItemSubTitleSelectedStyle}" />
198
- <Setter TargetName =" Hotkey" Property =" Style" Value =" {DynamicResource ItemHotkeySelectedStyle}" />
199
- <Setter TargetName =" ImageIcon" Property =" Style" Value =" {DynamicResource ItemImageSelectedStyle}" />
200
- <Setter TargetName =" GlyphIcon" Property =" Style" Value =" {DynamicResource ItemGlyphSelectedStyle}" />
206
+ <DataTrigger
207
+ Binding =" {Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}}, Path=IsSelected}"
208
+ Value =" True" >
209
+ <Setter TargetName =" Bullet"
210
+ Property =" Style"
211
+ Value =" {DynamicResource ItemBulletSelectedStyle}" />
212
+ <Setter TargetName =" Title"
213
+ Property =" Style"
214
+ Value =" {DynamicResource ItemTitleSelectedStyle}" />
215
+ <Setter TargetName =" SubTitle"
216
+ Property =" Style"
217
+ Value =" {DynamicResource ItemSubTitleSelectedStyle}" />
218
+ <Setter TargetName =" Hotkey"
219
+ Property =" Style"
220
+ Value =" {DynamicResource ItemHotkeySelectedStyle}" />
221
+ <Setter TargetName =" ImageIcon"
222
+ Property =" Style"
223
+ Value =" {DynamicResource ItemImageSelectedStyle}" />
224
+ <Setter TargetName =" GlyphIcon"
225
+ Property =" Style"
226
+ Value =" {DynamicResource ItemGlyphSelectedStyle}" />
201
227
</DataTrigger >
202
228
</DataTemplate .Triggers>
203
229
</DataTemplate >
204
230
</ListBox .ItemTemplate>
205
231
<!-- http://stackoverflow.com/questions/16819577/setting-background-color-or-wpf-4-0-listbox-windows-8/#16820062 -->
206
232
<ListBox .ItemContainerStyle>
207
233
<Style TargetType =" {x:Type ListBoxItem}" >
208
- <EventSetter Event =" MouseEnter" Handler =" OnMouseEnter" />
209
- <EventSetter Event =" MouseMove" Handler =" OnMouseMove" />
210
- <Setter Property =" Height" Value =" 52" />
211
- <Setter Property =" Margin" Value =" 0" />
212
- <Setter Property =" Padding" Value =" 0" />
213
- <Setter Property =" BorderThickness" Value =" 0" />
234
+ <EventSetter Event =" MouseEnter"
235
+ Handler =" OnMouseEnter" />
236
+ <EventSetter Event =" MouseMove"
237
+ Handler =" OnMouseMove" />
238
+ <Setter Property =" Height"
239
+ Value =" {DynamicResource ResultItemHeight}" />
240
+ <Setter Property =" Margin"
241
+ Value =" 0" />
242
+ <Setter Property =" Padding"
243
+ Value =" 0" />
244
+ <Setter Property =" BorderThickness"
245
+ Value =" 0" />
214
246
<Setter Property =" Template" >
215
247
<Setter .Value>
216
248
<ControlTemplate TargetType =" {x:Type ListBoxItem}" >
217
- <Border
218
- x : Name =" Bd"
249
+ <Border x : Name =" Bd"
219
250
Margin =" {DynamicResource ItemMargin}"
220
251
Background =" {TemplateBinding Background}"
221
252
BorderBrush =" {TemplateBinding BorderBrush}"
222
253
CornerRadius =" {DynamicResource ItemRadius}"
223
254
SnapsToDevicePixels =" True" >
224
- <ContentPresenter
225
- HorizontalAlignment =" {TemplateBinding HorizontalContentAlignment}"
255
+ <ContentPresenter HorizontalAlignment =" {TemplateBinding HorizontalContentAlignment}"
226
256
VerticalAlignment =" {TemplateBinding VerticalContentAlignment}"
227
257
Content =" {TemplateBinding Content}"
228
258
ContentStringFormat =" {TemplateBinding ContentStringFormat}"
229
259
ContentTemplate =" {TemplateBinding ContentTemplate}"
230
260
SnapsToDevicePixels =" {TemplateBinding SnapsToDevicePixels}" />
231
261
</Border >
232
262
<ControlTemplate .Triggers>
233
- <Trigger Property =" IsSelected" Value =" True" >
234
- <Setter TargetName =" Bd" Property =" Background" Value =" {DynamicResource ItemSelectedBackgroundColor}" />
235
- <Setter TargetName =" Bd" Property =" BorderBrush" Value =" {DynamicResource ItemSelectedBackgroundColor}" />
263
+ <Trigger Property =" IsSelected"
264
+ Value =" True" >
265
+ <Setter TargetName =" Bd"
266
+ Property =" Background"
267
+ Value =" {DynamicResource ItemSelectedBackgroundColor}" />
268
+ <Setter TargetName =" Bd"
269
+ Property =" BorderBrush"
270
+ Value =" {DynamicResource ItemSelectedBackgroundColor}" />
236
271
</Trigger >
237
272
</ControlTemplate .Triggers>
238
273
</ControlTemplate >
239
274
</Setter .Value>
240
275
</Setter >
241
276
</Style >
242
277
</ListBox .ItemContainerStyle>
243
- </ListBox >
278
+ </ListBox >
0 commit comments