Modal x Modeless Windows

Modal x Modeless Windows

xaotix
Contributor Contributor
299 Views
3 Replies
Message 1 of 4

Modal x Modeless Windows

xaotix
Contributor
Contributor

I have various windows in WPF in project.

 

They are working fine when I call them by modal:

.ShowWindow()

Now I want the user to be able to interact with the model.
So I switched to modeless:

.Show()

But after that, all the textboxes are frozen.

 

How I can achieve this?

0 Likes
Accepted solutions (1)
300 Views
3 Replies
Replies (3)
Message 2 of 4

ahmed.elhawary73
Advocate
Advocate
Accepted solution

@xaotix 

I faced this issue before, and this worked with me:

 

 MyForm form= new MyForm();

 ElementHost.EnableModelessKeyboardInterop(form);
 IntPtr hwnd = NavisworksHelper.GetNavisworksMainWindowHandle();
 WindowInteropHelper helper = new WindowInteropHelper(form);
 helper.EnsureHandle();
 helper.Owner = hwnd;
 form.Show();

If it worked please accept as solution

Message 3 of 4

xaotix
Contributor
Contributor

Thx a lot.

Worked like a charm!

 

The only thing that I needed to find out was what your GetNavisworksMainWindowHandle do.

 

 

            ElementHost.EnableModelessKeyboardInterop(window);
            IntPtr hwnd = ((MainWindow)Autodesk.Navisworks.Api.Application.Gui.MainWindow).Handle;
            WindowInteropHelper helper = new WindowInteropHelper(window);
            helper.EnsureHandle();
            helper.Owner = hwnd;
            window.Show();

 

0 Likes
Message 4 of 4

ahmed.elhawary73
Advocate
Advocate

I'm glade to help

0 Likes