-
Notifications
You must be signed in to change notification settings - Fork 136
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
Source codes:
// Build context menu using FluentAvalonia MenuFlyout to reliably show at pointer
var menu = new MenuFlyout();
void AddMenuItem(string header, string glyph, bool isEnabled, Action action)
{
var mi = new MenuItem
{
Header = header,
/*IconSource = new FontIconSource
{
Glyph = glyph
},*/
IsEnabled = isEnabled
};
mi.Click += (s, _) => action();
menu.Items.Add(mi);
}
void AddSeparator()
{
menu.Items.Add(new Separator());
}
AddMenuItem(Localize.MainWindow_Cut(), "\uE8C6", hasSelection, Cut);
AddMenuItem(Localize.MainWindow_Copy(), "\uE8C8", hasSelection, Copy);
AddMenuItem(Localize.MainWindow_Paste(), "\uE77F", canPaste, Paste);
AddMenuItem(Localize.MainWindow_Delete(), "\uE74D", hasSelection, DeleteSelection);
// Show at mouse position
menu.ShowAt(this, true);
When I hover my mouse on this MenuFlyout, it throws this exception:
System.NullReferenceException: Object reference not set to an instance of an object.
Source: FluentAvalonia
TargetAssembly: FluentAvalonia, Version=2.4.0.0, Culture=neutral, PublicKeyToken=null
TargetModule: FluentAvalonia.dll
TargetSite: Void OnPointerEntered(Avalonia.Input.PointerEventArgs)
at FluentAvalonia.UI.Controls.MenuFlyoutItemBase.OnPointerEntered(PointerEventArgs e)
at Avalonia.Input.InputElement.OnPointerEnteredCore(PointerEventArgs e)
at Avalonia.Input.InputElement.<>c.<.cctor>b__33_5(InputElement x, PointerEventArgs e)
at Avalonia.Reactive.LightweightObservableBase`1.PublishNext(T value)
at Avalonia.Interactivity.EventRoute.RaiseEventImpl(RoutedEventArgs e)
at Avalonia.Interactivity.EventRoute.RaiseEvent(Interactive source, RoutedEventArgs e)
at Avalonia.Interactivity.Interactive.RaiseEvent(RoutedEventArgs e)
at Avalonia.Input.PointerOverPreProcessor.SetPointerOverToElement(IPointer pointer, IInputRoot root, IInputElement element, UInt64 timestamp, Point position, PointerPointProperties properties, KeyModifiers inputModifiers)
at Avalonia.Input.PointerOverPreProcessor.OnNext(RawInputEventArgs value)
at Avalonia.Reactive.LightweightObservableBase`1.PublishNext(T value)
at Avalonia.Controls.TopLevel.<>c.<HandleInput>b__150_0(Object state)
at Avalonia.Threading.Dispatcher.Send(SendOrPostCallback action, Object arg, Nullable`1 priority)
Note that here MenuFltyout is Avalonia.Controls.MenuFltyout
Screenshots
.
Desktop/Platform (please complete the following information):
- OS: Windows 11
- FluentAvalonia Version: 2.4.0
- Avalonia Version: 11.3.8
Additional context
.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working