mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 04:07:40 +02:00
@@ -16,7 +16,8 @@
|
|||||||
KeyboardNavigation.DirectionalNavigation="Cycle" SelectionMode="Single"
|
KeyboardNavigation.DirectionalNavigation="Cycle" SelectionMode="Single"
|
||||||
VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Standard"
|
VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Standard"
|
||||||
SelectionChanged="OnSelectionChanged"
|
SelectionChanged="OnSelectionChanged"
|
||||||
IsSynchronizedWithCurrentItem="True">
|
IsSynchronizedWithCurrentItem="True"
|
||||||
|
PreviewMouseDown="ListBox_PreviewMouseDown">
|
||||||
<!--IsSynchronizedWithCurrentItem: http://stackoverflow.com/a/7833798/2833083-->
|
<!--IsSynchronizedWithCurrentItem: http://stackoverflow.com/a/7833798/2833083-->
|
||||||
<ListBox.ItemTemplate>
|
<ListBox.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
@@ -65,6 +66,7 @@
|
|||||||
<ListBox.ItemContainerStyle>
|
<ListBox.ItemContainerStyle>
|
||||||
<Style TargetType="{x:Type ListBoxItem}">
|
<Style TargetType="{x:Type ListBoxItem}">
|
||||||
<EventSetter Event="MouseEnter" Handler="OnMouseEnter" />
|
<EventSetter Event="MouseEnter" Handler="OnMouseEnter" />
|
||||||
|
<EventSetter Event="MouseMove" Handler="OnMouseMove" />
|
||||||
<Setter Property="Height" Value="50" />
|
<Setter Property="Height" Value="50" />
|
||||||
<Setter Property="Margin" Value="0" />
|
<Setter Property="Margin" Value="0" />
|
||||||
<Setter Property="Padding" Value="0" />
|
<Setter Property="Padding" Value="0" />
|
||||||
@@ -96,4 +98,4 @@
|
|||||||
</Setter>
|
</Setter>
|
||||||
</Style>
|
</Style>
|
||||||
</ListBox.ItemContainerStyle>
|
</ListBox.ItemContainerStyle>
|
||||||
</ListBox>
|
</ListBox>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Runtime.Remoting.Contexts;
|
using System.Runtime.Remoting.Contexts;
|
||||||
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
|
|
||||||
@@ -7,6 +8,8 @@ namespace Wox
|
|||||||
[Synchronization]
|
[Synchronization]
|
||||||
public partial class ResultListBox
|
public partial class ResultListBox
|
||||||
{
|
{
|
||||||
|
private Point _lastpos;
|
||||||
|
private ListBoxItem curItem = null;
|
||||||
public ResultListBox()
|
public ResultListBox()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@@ -22,7 +25,26 @@ namespace Wox
|
|||||||
|
|
||||||
private void OnMouseEnter(object sender, MouseEventArgs e)
|
private void OnMouseEnter(object sender, MouseEventArgs e)
|
||||||
{
|
{
|
||||||
((ListBoxItem) sender).IsSelected = true;
|
curItem = (ListBoxItem)sender;
|
||||||
|
var p = e.GetPosition((IInputElement)sender);
|
||||||
|
_lastpos = p;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnMouseMove(object sender, MouseEventArgs e)
|
||||||
|
{
|
||||||
|
var p = e.GetPosition((IInputElement)sender);
|
||||||
|
if (_lastpos != p)
|
||||||
|
{
|
||||||
|
((ListBoxItem) sender).IsSelected = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ListBox_PreviewMouseDown(object sender, MouseButtonEventArgs e)
|
||||||
|
{
|
||||||
|
if (curItem != null)
|
||||||
|
{
|
||||||
|
curItem.IsSelected = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user