Reintroduce hover state of list items

Items were immediately selected when mouse hovered over
This commit is contained in:
Peter Kirmeier 2023-09-17 19:11:08 +02:00
parent 569722a5b0
commit b00092e4a5
3 changed files with 7 additions and 21 deletions

View file

@ -32,7 +32,6 @@ namespace SystemTrayMenu.Business
{
if (MouseActive)
{
MouseSelect?.Invoke(itemData);
timerStartLoad.Stop();
StopLoadMenu?.Invoke();
SetData(itemData);
@ -72,6 +71,7 @@ namespace SystemTrayMenu.Business
StopLoadMenu?.Invoke();
SetData(itemData);
MouseActive = true;
MouseSelect?.Invoke(itemData);
OpenSubMenu();
}
@ -88,6 +88,11 @@ namespace SystemTrayMenu.Business
{
timerStartLoad.Stop();
StopLoadMenu?.Invoke();
if (MouseActive && currentItemData != null)
{
MouseSelect?.Invoke(currentItemData);
}
OpenSubMenu();
}

View file

@ -176,7 +176,7 @@
<ListView x:Name="dgv" x:FieldModifier="internal" Margin="6,1,6,1" Padding="0" d:ItemsSource="{d:SampleData ItemCount=50}" SelectionMode="Single" HorizontalContentAlignment="Stretch"
Background="{x:Null}" BorderThickness="0" VirtualizingStackPanel.IsVirtualizing="False"
SelectionChanged="ListView_SelectionChanged" MouseLeave="ListView_MouseLeave"
SelectionChanged="ListView_SelectionChanged"
ScrollViewer.CanContentScroll="True" ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.ScrollChanged="HandleScrollChanged">
<!--ListView."Childs".Border.Padding="0" // In ctor, see: dgv_border -->
<ListView.Resources>

View file

@ -1117,25 +1117,6 @@ namespace SystemTrayMenu.UserInterface
}
}
private void ListView_MouseLeave(object sender, MouseEventArgs e)
{
// In case a sub menu is already open and another item was already selected
// but WaitToLoadMenu hasn't take action yet
// then we want to reset that selection, so the sub menu selection remains active only
if (SubMenu != null)
{
ListView lv = (ListView)sender;
foreach (RowData itemData in lv.Items)
{
if (itemData.SubMenu == SubMenu)
{
lv.SelectedItem = itemData;
break;
}
}
}
}
private void ListView_CollectionChanged(object? sender, NotifyCollectionChangedEventArgs e)
{
int count = dgv.Items.Count;