mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
fix selected item doesn't always be the first item issue.
Method: Not only update selected index, but also update selected item when adding results.
This commit is contained in:
parent
05aa7062d7
commit
813e9b5439
2 changed files with 5 additions and 11 deletions
|
|
@ -9,7 +9,7 @@
|
|||
d:DataContext="{d:DesignInstance vm:ResultsViewModel}"
|
||||
MaxHeight="{Binding MaxHeight}"
|
||||
SelectedIndex="{Binding SelectedIndex, Mode=TwoWay}"
|
||||
SelectedItem="{Binding SelectedItem, Mode=OneWayToSource}"
|
||||
SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
|
||||
HorizontalContentAlignment="Stretch" ItemsSource="{Binding Results}"
|
||||
Margin="{Binding Margin}"
|
||||
Visibility="{Binding Visbility}"
|
||||
|
|
|
|||
|
|
@ -144,11 +144,10 @@ namespace Flow.Launcher.ViewModel
|
|||
{
|
||||
// https://social.msdn.microsoft.com/Forums/vstudio/en-US/5ff71969-f183-4744-909d-50f7cd414954/binding-a-tabcontrols-selectedindex-not-working?forum=wpf
|
||||
// fix selected index flow
|
||||
if (Results.Count > 0)
|
||||
SelectedIndex = 0;
|
||||
|
||||
// update UI in one run, so it can avoid UI flickering
|
||||
Results.Update(newResults);
|
||||
SelectedItem = newResults[0];
|
||||
}
|
||||
|
||||
if (Visbility != Visibility.Visible && Results.Count > 0)
|
||||
|
|
@ -176,9 +175,11 @@ namespace Flow.Launcher.ViewModel
|
|||
{
|
||||
// https://social.msdn.microsoft.com/Forums/vstudio/en-US/5ff71969-f183-4744-909d-50f7cd414954/binding-a-tabcontrols-selectedindex-not-working?forum=wpf
|
||||
// fix selected index flow
|
||||
SelectedIndex = 0;
|
||||
|
||||
Results.Update(newResults, token);
|
||||
SelectedItem = newResults[0];
|
||||
|
||||
|
||||
}
|
||||
|
||||
switch (Visbility)
|
||||
|
|
@ -321,13 +322,6 @@ namespace Flow.Launcher.ViewModel
|
|||
editTime++;
|
||||
return;
|
||||
}
|
||||
else if (editTime < 15 || newItems.Count < 50)
|
||||
{
|
||||
ClearItems();
|
||||
AddRange(newItems);
|
||||
editTime++;
|
||||
return;
|
||||
}
|
||||
Clear();
|
||||
|
||||
BulkAddRange(newItems);
|
||||
|
|
|
|||
Loading…
Reference in a new issue