mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Recycle items for result list box
This commit is contained in:
parent
83883c4b05
commit
0364fafdf0
2 changed files with 10 additions and 7 deletions
|
|
@ -27,7 +27,7 @@
|
|||
Style="{DynamicResource BaseListboxStyle}"
|
||||
VirtualizingPanel.ScrollUnit="Item"
|
||||
VirtualizingStackPanel.IsVirtualizing="True"
|
||||
VirtualizingStackPanel.VirtualizationMode="Standard"
|
||||
VirtualizingStackPanel.VirtualizationMode="Recycling"
|
||||
Visibility="{Binding Visibility}"
|
||||
mc:Ignorable="d">
|
||||
<!-- IsSynchronizedWithCurrentItem: http://stackoverflow.com/a/7833798/2833083 -->
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ namespace Flow.Launcher
|
|||
{
|
||||
protected Lock _lock = new();
|
||||
private Point _lastpos;
|
||||
private ListBoxItem curItem = null;
|
||||
private ResultViewModel _currentResult = null;
|
||||
public ResultListBox()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
|
@ -60,9 +60,12 @@ namespace Flow.Launcher
|
|||
{
|
||||
lock (_lock)
|
||||
{
|
||||
curItem = (ListBoxItem)sender;
|
||||
var p = e.GetPosition((IInputElement)sender);
|
||||
_lastpos = p;
|
||||
if (sender is FrameworkElement { DataContext: ResultViewModel result })
|
||||
{
|
||||
_currentResult = result;
|
||||
var p = e.GetPosition((IInputElement)sender);
|
||||
_lastpos = p;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -82,9 +85,9 @@ namespace Flow.Launcher
|
|||
{
|
||||
lock (_lock)
|
||||
{
|
||||
if (curItem != null)
|
||||
if (_currentResult != null && sender is ListBox listBox)
|
||||
{
|
||||
curItem.IsSelected = true;
|
||||
listBox.SelectedItem = _currentResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue