|
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 --> |
23 | 30 |
|
24 | 31 | <ListBox.ItemTemplate>
|
25 | 32 | <DataTemplate>
|
|
30 | 37 | </ControlTemplate>
|
31 | 38 | </Button.Template>
|
32 | 39 | <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"> |
35 | 46 | <Grid.Resources>
|
36 |
| - <converter:HighlightTextConverter x:Key="HighlightTextConverter"/> |
| 47 | + <converter:HighlightTextConverter x:Key="HighlightTextConverter" /> |
37 | 48 | <converter:OrdinalConverter x:Key="OrdinalConverter" />
|
38 | 49 | <converter:OpenResultHotkeyVisibilityConverter x:Key="OpenResultHotkeyVisibilityConverter" />
|
39 | 50 | </Grid.Resources>
|
40 | 51 | <Grid.ColumnDefinitions>
|
41 | 52 | <ColumnDefinition Width="60" />
|
42 |
| - <ColumnDefinition Width="*"/> |
| 53 | + <ColumnDefinition Width="*" /> |
43 | 54 | <ColumnDefinition Width="Auto" />
|
44 | 55 | </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}"> |
47 | 68 | <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}" /> |
49 | 70 | </TextBlock.Visibility>
|
50 | 71 | <TextBlock.Text>
|
51 | 72 | <MultiBinding StringFormat="{}{0}+{1}">
|
52 | 73 | <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}" /> |
54 | 75 | </MultiBinding>
|
55 | 76 | </TextBlock.Text>
|
56 | 77 | </TextBlock>
|
57 | 78 | </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}" /> |
60 | 92 | </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}" /> |
63 | 105 | </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"> |
65 | 110 | <Grid.RowDefinitions>
|
66 | 111 | <RowDefinition />
|
67 |
| - <RowDefinition Height="Auto" x:Name="SubTitleRowDefinition" /> |
| 112 | + <RowDefinition x:Name="SubTitleRowDefinition" Height="Auto" /> |
68 | 113 | </Grid.RowDefinitions>
|
69 | 114 |
|
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}"> |
73 | 122 | <vm:ResultsViewModel.FormattedText>
|
74 | 123 | <MultiBinding Converter="{StaticResource HighlightTextConverter}">
|
75 | 124 | <Binding Path="Result.Title" />
|
76 | 125 | <Binding Path="Result.TitleHighlightData" />
|
77 | 126 | </MultiBinding>
|
78 | 127 | </vm:ResultsViewModel.FormattedText>
|
79 | 128 | </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}"> |
82 | 136 | <vm:ResultsViewModel.FormattedText>
|
83 | 137 | <MultiBinding Converter="{StaticResource HighlightTextConverter}">
|
84 | 138 | <Binding Path="Result.SubTitle" />
|
|
92 | 146 | </Grid>
|
93 | 147 | </Button.Content>
|
94 | 148 | </Button>
|
95 |
| - <!-- a result item height is 52 including margin --> |
| 149 | + <!-- a result item height is 52 including margin --> |
96 | 150 | <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"> |
100 | 152 | <Setter TargetName="Title" Property="Style" Value="{DynamicResource ItemTitleSelectedStyle}" />
|
101 | 153 | <Setter TargetName="SubTitle" Property="Style" Value="{DynamicResource ItemSubTitleSelectedStyle}" />
|
102 | 154 | <Setter TargetName="Hotkey" Property="Style" Value="{DynamicResource ItemHotkeySelectedStyle}" />
|
|
105 | 157 | </DataTemplate.Triggers>
|
106 | 158 | </DataTemplate>
|
107 | 159 | </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 --> |
109 | 161 | <ListBox.ItemContainerStyle>
|
110 | 162 | <Style TargetType="{x:Type ListBoxItem}">
|
111 | 163 | <EventSetter Event="MouseEnter" Handler="OnMouseEnter" />
|
|
117 | 169 | <Setter Property="Template">
|
118 | 170 | <Setter.Value>
|
119 | 171 | <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}" /> |
130 | 184 | </Border>
|
131 | 185 | <ControlTemplate.Triggers>
|
132 | 186 | <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}" /> |
137 | 189 | </Trigger>
|
138 | 190 | </ControlTemplate.Triggers>
|
139 | 191 | </ControlTemplate>
|
|
0 commit comments