Skip to content

Commit 4602338

Browse files
committed
1 parent 86f981f commit 4602338

2 files changed

Lines changed: 15 additions & 26 deletions

File tree

Wox/ResultListBox.xaml

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
xmlns:vm="clr-namespace:Wox.ViewModel"
77
mc:Ignorable="d" d:DesignWidth="100" d:DesignHeight="100"
88
d:DataContext="{d:DesignInstance vm:ResultsViewModel}"
9-
MaxHeight="{Binding MaxHeight}"
9+
MaxHeight="{Binding MaxHeight}"
1010
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}"
1313
Margin="{Binding Margin}"
14-
Style="{DynamicResource BaseListboxStyle}" Focusable="False"
14+
Style="{DynamicResource BaseListboxStyle}" Focusable="False"
1515
KeyboardNavigation.DirectionalNavigation="Cycle" SelectionMode="Single"
1616
VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Standard"
1717
SelectionChanged="OnSelectionChanged"
@@ -26,7 +26,7 @@
2626
</ControlTemplate>
2727
</Button.Template>
2828
<Button.Content>
29-
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="5"
29+
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="5"
3030
Cursor="Hand" UseLayoutRounding="False">
3131
<Grid.ColumnDefinitions>
3232
<ColumnDefinition Width="32" />
@@ -41,34 +41,33 @@
4141
<RowDefinition Height="Auto" x:Name="SubTitleRowDefinition" />
4242
</Grid.RowDefinitions>
4343
<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"
4545
Text="{Binding Title}" />
4646
<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}" />
4848
</Grid>
4949
</Grid>
5050
</Button.Content>
5151
</Button>
5252
<!-- a result item height is 50 including margin -->
5353
<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}" />
6059
</DataTrigger>
6160
</DataTemplate.Triggers>
6261
</DataTemplate>
6362
</ListBox.ItemTemplate>
6463
<!--http://stackoverflow.com/questions/16819577/setting-background-color-or-wpf-4-0-listbox-windows-8/#16820062-->
6564
<ListBox.ItemContainerStyle>
6665
<Style TargetType="{x:Type ListBoxItem}">
67-
<EventSetter Event="MouseEnter" Handler="OnMouseEnter"></EventSetter>
66+
<EventSetter Event="MouseEnter" Handler="OnMouseEnter" />
6867
<Setter Property="Height" Value="50" />
6968
<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" />
7271
<Setter Property="Template">
7372
<Setter.Value>
7473
<ControlTemplate TargetType="{x:Type ListBoxItem}">

Wox/ViewModel/ResultViewModel.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,6 @@ public Func<ActionContext, bool> Action
6363
set { RawResult.Action = value; }
6464
}
6565

66-
public bool IsSelected
67-
{
68-
get { return _isSelected; }
69-
set
70-
{
71-
_isSelected = value;
72-
OnPropertyChanged();
73-
}
74-
}
75-
7666
#endregion
7767

7868
#region Properties

0 commit comments

Comments
 (0)