Skip to content

Commit 4525043

Browse files
committed
Change Icon uniform property from uniformtofill (Fix wide icon cut)
1 parent eaf0649 commit 4525043

File tree

1 file changed

+112
-60
lines changed

1 file changed

+112
-60
lines changed

Flow.Launcher/ResultListBox.xaml

Lines changed: 112 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,32 @@
1-
<ListBox x:Class="Flow.Launcher.ResultListBox"
2-
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3-
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4-
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5-
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6-
xmlns:vm="clr-namespace:Flow.Launcher.ViewModel"
7-
xmlns:converter="clr-namespace:Flow.Launcher.Converters"
8-
mc:Ignorable="d" d:DesignWidth="100" d:DesignHeight="100"
9-
d:DataContext="{d:DesignInstance vm:ResultsViewModel}"
10-
MaxHeight="{Binding MaxHeight}"
11-
SelectedIndex="{Binding SelectedIndex, Mode=TwoWay}"
12-
SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
13-
HorizontalContentAlignment="Stretch" ItemsSource="{Binding Results}"
14-
Margin="{Binding Margin}"
15-
Visibility="{Binding Visbility}"
16-
Style="{DynamicResource BaseListboxStyle}" Focusable="False"
17-
KeyboardNavigation.DirectionalNavigation="Cycle" SelectionMode="Single"
18-
VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Standard"
19-
SelectionChanged="OnSelectionChanged"
20-
IsSynchronizedWithCurrentItem="True"
21-
PreviewMouseDown="ListBox_PreviewMouseDown">
22-
<!--IsSynchronizedWithCurrentItem: http://stackoverflow.com/a/7833798/2833083-->
1+
<ListBox
2+
x:Class="Flow.Launcher.ResultListBox"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:converter="clr-namespace:Flow.Launcher.Converters"
6+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
7+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
8+
xmlns:vm="clr-namespace:Flow.Launcher.ViewModel"
9+
MaxHeight="{Binding MaxHeight}"
10+
Margin="{Binding Margin}"
11+
HorizontalContentAlignment="Stretch"
12+
d:DataContext="{d:DesignInstance vm:ResultsViewModel}"
13+
d:DesignHeight="100"
14+
d:DesignWidth="100"
15+
Focusable="False"
16+
IsSynchronizedWithCurrentItem="True"
17+
ItemsSource="{Binding Results}"
18+
KeyboardNavigation.DirectionalNavigation="Cycle"
19+
PreviewMouseDown="ListBox_PreviewMouseDown"
20+
SelectedIndex="{Binding SelectedIndex, Mode=TwoWay}"
21+
SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
22+
SelectionChanged="OnSelectionChanged"
23+
SelectionMode="Single"
24+
Style="{DynamicResource BaseListboxStyle}"
25+
VirtualizingStackPanel.IsVirtualizing="True"
26+
VirtualizingStackPanel.VirtualizationMode="Standard"
27+
Visibility="{Binding Visbility}"
28+
mc:Ignorable="d">
29+
<!-- IsSynchronizedWithCurrentItem: http://stackoverflow.com/a/7833798/2833083 -->
2330

2431
<ListBox.ItemTemplate>
2532
<DataTemplate>
@@ -30,55 +37,102 @@
3037
</ControlTemplate>
3138
</Button.Template>
3239
<Button.Content>
33-
<Grid HorizontalAlignment="Left" VerticalAlignment="Stretch" Margin="0"
34-
Cursor="Hand" UseLayoutRounding="False">
40+
<Grid
41+
Margin="0"
42+
HorizontalAlignment="Left"
43+
VerticalAlignment="Stretch"
44+
Cursor="Hand"
45+
UseLayoutRounding="False">
3546
<Grid.Resources>
36-
<converter:HighlightTextConverter x:Key="HighlightTextConverter"/>
47+
<converter:HighlightTextConverter x:Key="HighlightTextConverter" />
3748
<converter:OrdinalConverter x:Key="OrdinalConverter" />
3849
<converter:OpenResultHotkeyVisibilityConverter x:Key="OpenResultHotkeyVisibilityConverter" />
3950
</Grid.Resources>
4051
<Grid.ColumnDefinitions>
4152
<ColumnDefinition Width="60" />
42-
<ColumnDefinition Width="*"/>
53+
<ColumnDefinition Width="*" />
4354
<ColumnDefinition Width="Auto" />
4455
</Grid.ColumnDefinitions>
45-
<StackPanel Visibility="{Binding ShowOpenResultHotkey}" Grid.Column="2" Margin="0 0 10 0">
46-
<TextBlock Margin="12 0 12 0" Style="{DynamicResource ItemHotkeyStyle}" HorizontalAlignment="Right" Opacity="0.8" VerticalAlignment="Center" Padding="0 10 0 10" x:Name="Hotkey">
56+
<StackPanel
57+
Grid.Column="2"
58+
Margin="0,0,10,0"
59+
Visibility="{Binding ShowOpenResultHotkey}">
60+
<TextBlock
61+
x:Name="Hotkey"
62+
Margin="12,0,12,0"
63+
Padding="0,10,0,10"
64+
HorizontalAlignment="Right"
65+
VerticalAlignment="Center"
66+
Opacity="0.8"
67+
Style="{DynamicResource ItemHotkeyStyle}">
4768
<TextBlock.Visibility>
48-
<Binding RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=ListBoxItem}" Converter="{StaticResource ResourceKey=OpenResultHotkeyVisibilityConverter}" />
69+
<Binding Converter="{StaticResource ResourceKey=OpenResultHotkeyVisibilityConverter}" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=ListBoxItem}" />
4970
</TextBlock.Visibility>
5071
<TextBlock.Text>
5172
<MultiBinding StringFormat="{}{0}+{1}">
5273
<Binding Path="OpenResultModifiers" />
53-
<Binding RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=ListBoxItem}" Converter="{StaticResource ResourceKey=OrdinalConverter}" />
74+
<Binding Converter="{StaticResource ResourceKey=OrdinalConverter}" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=ListBoxItem}" />
5475
</MultiBinding>
5576
</TextBlock.Text>
5677
</TextBlock>
5778
</StackPanel>
58-
<Border BorderThickness="0" BorderBrush="Transparent" Margin="9 0 0 0">
59-
<Image x:Name="ImageIcon" Width="32" Height="32" HorizontalAlignment="Center" Source="{Binding Image}" Visibility="{Binding ShowIcon}" Margin="0 0 0 0" Stretch="UniformToFill"/>
79+
<Border
80+
Margin="9,0,0,0"
81+
BorderBrush="Transparent"
82+
BorderThickness="0">
83+
<Image
84+
x:Name="ImageIcon"
85+
Width="32"
86+
Height="32"
87+
Margin="0,0,0,0"
88+
HorizontalAlignment="Center"
89+
Source="{Binding Image}"
90+
Stretch="Uniform"
91+
Visibility="{Binding ShowIcon}" />
6092
</Border>
61-
<Border BorderThickness="0" BorderBrush="Transparent" Margin="9 0 0 0">
62-
<TextBlock Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Center" Text="{Binding Glyph.Glyph}" FontFamily="{Binding Glyph.FontFamily}" Visibility="{Binding ShowGlyph}" Style="{DynamicResource ItemGlyph}"/>
93+
<Border
94+
Margin="9,0,0,0"
95+
BorderBrush="Transparent"
96+
BorderThickness="0">
97+
<TextBlock
98+
Grid.Column="0"
99+
HorizontalAlignment="Center"
100+
VerticalAlignment="Center"
101+
FontFamily="{Binding Glyph.FontFamily}"
102+
Style="{DynamicResource ItemGlyph}"
103+
Text="{Binding Glyph.Glyph}"
104+
Visibility="{Binding ShowGlyph}" />
63105
</Border>
64-
<Grid Margin="6 0 10 0" Grid.Column="1" HorizontalAlignment="Stretch">
106+
<Grid
107+
Grid.Column="1"
108+
Margin="6,0,10,0"
109+
HorizontalAlignment="Stretch">
65110
<Grid.RowDefinitions>
66111
<RowDefinition />
67-
<RowDefinition Height="Auto" x:Name="SubTitleRowDefinition" />
112+
<RowDefinition x:Name="SubTitleRowDefinition" Height="Auto" />
68113
</Grid.RowDefinitions>
69114

70-
<TextBlock Style="{DynamicResource ItemTitleStyle}" DockPanel.Dock="Left"
71-
VerticalAlignment="Center" ToolTip="{Binding ShowTitleToolTip}" x:Name="Title"
72-
Text="{Binding Result.Title}">
115+
<TextBlock
116+
x:Name="Title"
117+
VerticalAlignment="Center"
118+
DockPanel.Dock="Left"
119+
Style="{DynamicResource ItemTitleStyle}"
120+
Text="{Binding Result.Title}"
121+
ToolTip="{Binding ShowTitleToolTip}">
73122
<vm:ResultsViewModel.FormattedText>
74123
<MultiBinding Converter="{StaticResource HighlightTextConverter}">
75124
<Binding Path="Result.Title" />
76125
<Binding Path="Result.TitleHighlightData" />
77126
</MultiBinding>
78127
</vm:ResultsViewModel.FormattedText>
79128
</TextBlock>
80-
<TextBlock Style="{DynamicResource ItemSubTitleStyle}" ToolTip="{Binding ShowSubTitleToolTip}"
81-
Grid.Row="1" x:Name="SubTitle" Text="{Binding Result.SubTitle}" MinWidth="750">
129+
<TextBlock
130+
x:Name="SubTitle"
131+
Grid.Row="1"
132+
MinWidth="750"
133+
Style="{DynamicResource ItemSubTitleStyle}"
134+
Text="{Binding Result.SubTitle}"
135+
ToolTip="{Binding ShowSubTitleToolTip}">
82136
<vm:ResultsViewModel.FormattedText>
83137
<MultiBinding Converter="{StaticResource HighlightTextConverter}">
84138
<Binding Path="Result.SubTitle" />
@@ -92,11 +146,9 @@
92146
</Grid>
93147
</Button.Content>
94148
</Button>
95-
<!-- a result item height is 52 including margin -->
149+
<!-- a result item height is 52 including margin -->
96150
<DataTemplate.Triggers>
97-
<DataTrigger
98-
Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type ListBoxItem}}, Path=IsSelected}"
99-
Value="True">
151+
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}}, Path=IsSelected}" Value="True">
100152
<Setter TargetName="Title" Property="Style" Value="{DynamicResource ItemTitleSelectedStyle}" />
101153
<Setter TargetName="SubTitle" Property="Style" Value="{DynamicResource ItemSubTitleSelectedStyle}" />
102154
<Setter TargetName="Hotkey" Property="Style" Value="{DynamicResource ItemHotkeySelectedStyle}" />
@@ -105,7 +157,7 @@
105157
</DataTemplate.Triggers>
106158
</DataTemplate>
107159
</ListBox.ItemTemplate>
108-
<!--http://stackoverflow.com/questions/16819577/setting-background-color-or-wpf-4-0-listbox-windows-8/#16820062-->
160+
<!-- http://stackoverflow.com/questions/16819577/setting-background-color-or-wpf-4-0-listbox-windows-8/#16820062 -->
109161
<ListBox.ItemContainerStyle>
110162
<Style TargetType="{x:Type ListBoxItem}">
111163
<EventSetter Event="MouseEnter" Handler="OnMouseEnter" />
@@ -117,23 +169,23 @@
117169
<Setter Property="Template">
118170
<Setter.Value>
119171
<ControlTemplate TargetType="{x:Type ListBoxItem}">
120-
<Border x:Name="Bd"
121-
Background="{TemplateBinding Background}"
122-
BorderBrush="{TemplateBinding BorderBrush}"
123-
SnapsToDevicePixels="True">
124-
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
125-
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
126-
Content="{TemplateBinding Content}"
127-
ContentStringFormat="{TemplateBinding ContentStringFormat}"
128-
ContentTemplate="{TemplateBinding ContentTemplate}"
129-
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
172+
<Border
173+
x:Name="Bd"
174+
Background="{TemplateBinding Background}"
175+
BorderBrush="{TemplateBinding BorderBrush}"
176+
SnapsToDevicePixels="True">
177+
<ContentPresenter
178+
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
179+
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
180+
Content="{TemplateBinding Content}"
181+
ContentStringFormat="{TemplateBinding ContentStringFormat}"
182+
ContentTemplate="{TemplateBinding ContentTemplate}"
183+
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
130184
</Border>
131185
<ControlTemplate.Triggers>
132186
<Trigger Property="IsSelected" Value="True">
133-
<Setter TargetName="Bd" Property="Background"
134-
Value="{DynamicResource ItemSelectedBackgroundColor}" />
135-
<Setter TargetName="Bd" Property="BorderBrush"
136-
Value="{DynamicResource ItemSelectedBackgroundColor}" />
187+
<Setter TargetName="Bd" Property="Background" Value="{DynamicResource ItemSelectedBackgroundColor}" />
188+
<Setter TargetName="Bd" Property="BorderBrush" Value="{DynamicResource ItemSelectedBackgroundColor}" />
137189
</Trigger>
138190
</ControlTemplate.Triggers>
139191
</ControlTemplate>

0 commit comments

Comments
 (0)