Vault C# WPF multiple screen issue

Anonymous

Vault C# WPF multiple screen issue

Anonymous
Not applicable

I have a Vault WPF .NET C# plugin which opens a wpf window.

 

Now the issue is when multiple screens are connected.

WPF plugin opens only in the primary screen. not on he screen where vault is open.

 

Example,

Screen 1 is primary screen

Screen 2 is where vault client is open

 

When the plugin is fired it always opens in screen 1.

 

I want the plugin to open on the same screen where Vault client is open.

 

Any help would be appreciated.

0 Likes
Reply
Accepted solutions (1)
2,956 Views
2 Replies
Replies (2)

manuel.lanthaler
Enthusiast
Enthusiast
Accepted solution

Hello,

 

i think the solution is to set the Vault Client as Parent window for your WPF window.

You can achieve this by getting the MainWindowHandle from your current process (which is Vault becuause you have a Vault Addin) and then setting the Owner for your window.

 

Example:

using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Interop;
var myWindow = new Window(); //Your WPF window
var vaultHwnd = Process.GetCurrentProcess().MainWindowHandle; //Vault window handle
new WindowInteropHelper(myWindow) { Owner = vaultHwnd };
myWindow.ShowDialog();

 

Manuel

coolOrange
www.coolOrange.com
––––––––––––––––––
Please mark this response as "Accept as Solution" if it answers your question.
If you have found any post to be helpful, even if it's not a direct solution, then please provide that author kudos.


manuel.lanthaler
Enthusiast
Enthusiast

Additionally i would suggest to set the WindowsStartupLocation in your WPF Window to CenterOwner.

 

Set this in your Window.xaml : 

WindowStartupLocation="CenterOwner"
Manuel

coolOrange
www.coolOrange.com
––––––––––––––––––
Please mark this response as "Accept as Solution" if it answers your question.
If you have found any post to be helpful, even if it's not a direct solution, then please provide that author kudos.


Type a product name