question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Open context menu from Command crashes on rc1

See original GitHub issue

In preview6 this worked, however with rc1 it crash the program:

Sample:

<Button
              IsEnabled="{Binding SlicerFile.CreatedThumbnailsCount}"
              ToolTip.Tip="Save properties to a file or clipboard"
              Command="{Binding #PropertiesSaveContextMenu.Open}">
              <Button.ContextMenu>
                <ContextMenu Name="PropertiesSaveContextMenu" PlacementMode="Bottom">
                  <MenuItem
                    Command="{Binding OnClickPropertiesSaveFile}"
                    Header="To File">
                    <MenuItem.Icon>
                      <Image Source="/Assets/Icons/file-image-16x16.png"/>
                    </MenuItem.Icon>
                  </MenuItem>

                  <MenuItem
                    Command="{Binding OnClickPropertiesSaveClipboard}"
                    Header="To Clipboard">
                    <MenuItem.Icon>
                      <Image Source="/Assets/Icons/clipboard-16x16.png"/>
                    </MenuItem.Icon>
                  </MenuItem>

                </ContextMenu>
              </Button.ContextMenu>
              <StackPanel Orientation="Horizontal">
                <Image Source="/Assets/Icons/save-16x16.png" />
                <TextBlock Text=" ⮟"/>
              </StackPanel>
            </Button>

Problem:

Command="{Binding #PropertiesSaveContextMenu.Open}"

As soon i left click button it crashes. Right click still working and open the context menu. Is there anyway or property that i can set to make left click also open the context menu without the extra code?

Message: Specified method is not supported.

Strack Trace:

   at Avalonia.Controls.ContextMenu.Open()
   at Avalonia.Data.Converters.MethodToCommandConverter.Execute(Object parameter)
   at Avalonia.Controls.Button.OnClick()
   at Avalonia.Controls.Button.OnPointerReleased(PointerReleasedEventArgs e)
   at Avalonia.Input.InputElement.<>c.<.cctor>b__28_9(InputElement x, PointerReleasedEventArgs e)
   at System.Reactive.Subjects.Subject`1.OnNext(T value) in /_/Rx.NET/Source/src/System.Reactive/Subjects/Subject.cs:line 147
   at Avalonia.Interactivity.EventRoute.RaiseEventImpl(RoutedEventArgs e)
   at Avalonia.Interactivity.EventRoute.RaiseEvent(IInteractive source, RoutedEventArgs e)
   at Avalonia.Interactivity.Interactive.RaiseEvent(RoutedEventArgs e)
   at Avalonia.Input.MouseDevice.MouseUp(IMouseDevice device, UInt64 timestamp, IInputRoot root, Point p, PointerPointProperties props, KeyModifiers inputModifiers)
   at Avalonia.Input.MouseDevice.ProcessRawEvent(RawPointerEventArgs e)
   at Avalonia.Input.InputManager.ProcessInput(RawInputEventArgs e)
   at Avalonia.Win32.WindowImpl.AppWndProc(IntPtr hWnd, UInt32 msg, IntPtr wParam, IntPtr lParam)
   at Avalonia.Win32.WindowImpl.WndProc(IntPtr hWnd, UInt32 msg, IntPtr wParam, IntPtr lParam)
   at Avalonia.Win32.Interop.UnmanagedMethods.DispatchMessage(MSG& lpmsg)
   at Avalonia.Win32.Win32Platform.RunLoop(CancellationToken cancellationToken)
   at Avalonia.Threading.Dispatcher.MainLoop(CancellationToken cancellationToken)
   at Avalonia.Controls.ApplicationLifetimes.ClassicDesktopStyleApplicationLifetime.Start(String[] args)
   at Avalonia.ClassicDesktopStyleApplicationLifetimeExtensions.StartWithClassicDesktopLifetime[T](T builder, String[] args, ShutdownMode shutdownMode)
   at UVtools.WPF.Program.Main(String[] args) in D:\Tiago\Dropbox\Programming\C#\UVtools\UVtools.WPF\Program.cs:line 26

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:13 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
donandrencommented, Dec 18, 2020
item.ContextMenu.Open();// NotSupported
item.ContextMenu.Open(null);//working 

why not ContextMenu.Open() call ContextMenu.Open(null) instead throw NotSupported?

1reaction
maxkatz6commented, Dec 17, 2020

ContextMenu is planned to be reworked with Flyouts -see https://github.com/AvaloniaUI/Avalonia/issues/5172 But not for 0.10 release.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Explorer crashes when clicking on any context menu ...
Open up your Event Viewer and see if there's something specific that's causing the crash. Then use Nirsoft's ShellExView to disable it, ...
Read more >
72452 – crash when closing a document while a context ...
If there's an open context menu in the document window itself, then closing is denied. The same should happen in floating windows which...
Read more >
AMD Control Center crashing on right click context menu ...
Every time I right click to open the context menu the control center crashes. I can have the control center open, right click...
Read more >
MultiCommander v7.0.0 (RC)
FIXED - MultiScript debugger sometimes caused a crash if closed ... ADDED - Custom Context Menu that show internal command as submenu to...
Read more >
Firefox 4 RC 1 Fixes
See the complete list of bugs fixed by Firefox 4 RC 1. ... 636666, paste option doesn't appear in context menu for text...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found