|
6 | 6 | xmlns:vm="clr-namespace:Wox.ViewModel" |
7 | 7 | mc:Ignorable="d" d:DesignWidth="100" d:DesignHeight="100" |
8 | 8 | d:DataContext="{d:DesignInstance vm:ResultsViewModel}" |
9 | | - MaxHeight="{Binding MaxHeight}" |
| 9 | + MaxHeight="{Binding MaxHeight}" |
10 | 10 | SelectedIndex="{Binding SelectedIndex, Mode=TwoWay}" |
11 | | - SelectedItem="{Binding SelectedItem, Mode=OneWayToSource}" |
12 | | - HorizontalContentAlignment="Stretch" ItemsSource="{Binding Results}" |
| 11 | + SelectedItem="{Binding SelectedItem, Mode=OneWayToSource}" |
| 12 | + HorizontalContentAlignment="Stretch" ItemsSource="{Binding Results}" |
13 | 13 | Margin="{Binding Margin}" |
14 | | - Style="{DynamicResource BaseListboxStyle}" Focusable="False" |
| 14 | + Style="{DynamicResource BaseListboxStyle}" Focusable="False" |
15 | 15 | KeyboardNavigation.DirectionalNavigation="Cycle" SelectionMode="Single" |
16 | 16 | VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Standard" |
17 | 17 | SelectionChanged="OnSelectionChanged" |
|
26 | 26 | </ControlTemplate> |
27 | 27 | </Button.Template> |
28 | 28 | <Button.Content> |
29 | | - <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="5" |
| 29 | + <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="5" |
30 | 30 | Cursor="Hand" UseLayoutRounding="False"> |
31 | 31 | <Grid.ColumnDefinitions> |
32 | 32 | <ColumnDefinition Width="32" /> |
|
41 | 41 | <RowDefinition Height="Auto" x:Name="SubTitleRowDefinition" /> |
42 | 42 | </Grid.RowDefinitions> |
43 | 43 | <TextBlock Style="{DynamicResource ItemTitleStyle}" DockPanel.Dock="Left" |
44 | | - VerticalAlignment="Center" ToolTip="{Binding Title}" x:Name="tbTitle" |
| 44 | + VerticalAlignment="Center" ToolTip="{Binding Title}" x:Name="Title" |
45 | 45 | Text="{Binding Title}" /> |
46 | 46 | <TextBlock Style="{DynamicResource ItemSubTitleStyle}" ToolTip="{Binding SubTitle}" |
47 | | - Grid.Row="1" x:Name="tbSubTitle" Text="{Binding SubTitle}" /> |
| 47 | + Grid.Row="1" x:Name="SubTitle" Text="{Binding SubTitle}" /> |
48 | 48 | </Grid> |
49 | 49 | </Grid> |
50 | 50 | </Button.Content> |
51 | 51 | </Button> |
52 | 52 | <!-- a result item height is 50 including margin --> |
53 | 53 | <DataTemplate.Triggers> |
54 | | - <DataTrigger Binding="{Binding Path=IsSelected}" Value="True"> |
55 | | - <Setter TargetName="tbTitle" Property="Style" Value="{DynamicResource ItemTitleSelectedStyle}" /> |
56 | | - </DataTrigger> |
57 | | - <DataTrigger Binding="{Binding Path=IsSelected}" Value="True"> |
58 | | - <Setter TargetName="tbSubTitle" Property="Style" |
59 | | - Value="{DynamicResource ItemSubTitleSelectedStyle}" /> |
| 54 | + <DataTrigger |
| 55 | + Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type ListBoxItem}}, Path=IsSelected}" |
| 56 | + Value="True"> |
| 57 | + <Setter TargetName="Title" Property="Style" Value="{DynamicResource ItemTitleSelectedStyle}" /> |
| 58 | + <Setter TargetName="SubTitle" Property="Style" Value="{DynamicResource ItemSubTitleSelectedStyle}" /> |
60 | 59 | </DataTrigger> |
61 | 60 | </DataTemplate.Triggers> |
62 | 61 | </DataTemplate> |
63 | 62 | </ListBox.ItemTemplate> |
64 | 63 | <!--http://stackoverflow.com/questions/16819577/setting-background-color-or-wpf-4-0-listbox-windows-8/#16820062--> |
65 | 64 | <ListBox.ItemContainerStyle> |
66 | 65 | <Style TargetType="{x:Type ListBoxItem}"> |
67 | | - <EventSetter Event="MouseEnter" Handler="OnMouseEnter"></EventSetter> |
| 66 | + <EventSetter Event="MouseEnter" Handler="OnMouseEnter" /> |
68 | 67 | <Setter Property="Height" Value="50" /> |
69 | 68 | <Setter Property="Margin" Value="0" /> |
70 | | - <Setter Property="Padding" Value="0"/> |
71 | | - <Setter Property="BorderThickness" Value="0"/> |
| 69 | + <Setter Property="Padding" Value="0" /> |
| 70 | + <Setter Property="BorderThickness" Value="0" /> |
72 | 71 | <Setter Property="Template"> |
73 | 72 | <Setter.Value> |
74 | 73 | <ControlTemplate TargetType="{x:Type ListBoxItem}"> |
|
0 commit comments