Skip to content

Create a window with an NSPanel #18391

Answered by Linlccc
Linlccc asked this question in Q&A
Discussion options

You must be logged in to vote

Based on the sample suggested by @maxkatz6, I simply wrote a NSPanel creation in Avalonia that works with the local API.

[SupportedOSPlatform("macos")]
public class AvNsPanel : EmbeddableControlRoot, IDisposable
{
    /// <summary>
    /// NSPanel's handle
    /// </summary>
    private readonly IntPtr _nsPanelHandle;

    /// <summary>
    /// Avalonia's root control handle
    /// </summary>
    private IMacOSTopLevelPlatformHandle AvaloniaRootHandle
    {
        get
        {
            if (TryGetPlatformHandle() is not IMacOSTopLevelPlatformHandle platformHandle) throw new InvalidOperationException("Platform handle is not available.");
            return platformHandle;
        }
  …

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@Linlccc
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by Linlccc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants