Skip to content

Show modal dialog window from WinFormsAvaloniaControlHost #15977

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

You must be logged in to vote

Thanks @maxkatz6 . I was able to get it to work following your instructions, I had to make a few changes, here is the code that worked for me to show a modal Avalonia Window from a WinForm app:

    public static void ShowModalWindow(System.Windows.Forms.Form winForm, Avalonia.Controls.Window avaloniaWindow)
    {
        var parentHandle = winForm.Handle;
        var dialogHandle = avaloniaWindow.TryGetPlatformHandle().Handle;
        SetWindowLong(dialogHandle, GWLP_HWNDPARENT, parentHandle);

        avaloniaWindow.Show();
        avaloniaWindow.Closed += (sender, args) => 
            {
                EnableWindow(parentHandle, true);
                SetWindowPos(parentHandle, HWND_TO…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@maxkatz6
Comment options

@pauldumais
Comment options

Answer selected by maxkatz6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants