mirror of
https://github.com/MaSzyna-EU07/StarterNG.git
synced 2026-11-19 15:02:15 +01:00
Find the list item under the pointer with FindAncestorOfType
This commit is contained in:
@@ -11,6 +11,7 @@ using Avalonia.Layout;
|
||||
using Avalonia.Media;
|
||||
using Avalonia.Media.Imaging;
|
||||
using Avalonia.Threading;
|
||||
using Avalonia.VisualTree;
|
||||
|
||||
using StarterNG.Classes;
|
||||
using StarterNG.Domain;
|
||||
@@ -363,11 +364,8 @@ public sealed class VehicleBrowser
|
||||
|
||||
private void List_OnContextRequested(object? sender, ContextRequestedEventArgs e)
|
||||
{
|
||||
var hit = e.Source as Control;
|
||||
while (hit != null && hit is not ListBoxItem)
|
||||
hit = hit.Parent as Control;
|
||||
|
||||
if (hit is not ListBoxItem { Tag: VehicleTexture texture })
|
||||
if ((e.Source as Visual).FindAncestorOfType<ListBoxItem>(includeSelf: true) is not
|
||||
{ Tag: VehicleTexture texture } hit)
|
||||
return;
|
||||
|
||||
BuildBrowserMenu(texture, hit).Open(hit);
|
||||
|
||||
Reference in New Issue
Block a user