Select to view content in your preferred language

ProWindow Position on Screen

741
4
Jump to solution
05-13-2023 12:28 PM
DaveLewis73
Occasional Contributor

I am having extreme difficulties getting a ProWindow to display where I want it to.  It doesn't matter how I define the window (either in XAML or programmatically), the window always displays in the same location that it was last located when it last closed.  I can set the WindowStartupLocation to "CenterOwner" with the Owner set to the Application.Current.MainWindow, which should open the window in the center of the Pro application.  However, that doesn't work.  I can also set the owner to be the center of another window and that doesn't work.  Additionally, just for testing purposes, I can set the WindowStartupLocation to "Manual" and define a top and left for the window, but that doesn't work.  It doesn't matter what I do, the result is always the same.  The window just opens in the last location that it was closed.  This is clearly a problem.  As an fyi, I am developing with the C# SDK for ArcGIS Pro in 3.1.1.  Does anyone have any idea what could be causing this problem?

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
CharlesMacleod
Esri Regular Contributor

Hi Dave, can u try:

_proWindow.SaveWindowPosition = false;//override last position of the window 

we will make sure this gets added to the Pro SDK documentation. 

View solution in original post

4 Replies
CharlesMacleod
Esri Regular Contributor

Hi Dave, can u try:

_proWindow.SaveWindowPosition = false;//override last position of the window 

we will make sure this gets added to the Pro SDK documentation. 

RejeanLabbe
New Contributor III

I also came across this problem and I just want to add that it can be done in XAML.

<controls:ProWindow
    SaveWindowPosition="False"
>

 

0 Kudos
DaveLewis73
Occasional Contributor

Charlie,

Thank you!  That works perfectly and was just what I needed.

0 Kudos
Wolf
by Esri Regular Contributor
Esri Regular Contributor

Just for others looking for the complete snippet that will allow to manually position the popup window (works for both Show() and ShowDialog()):

protected override void OnClick()
{
  //already open?
  if (_prowindow != null)
    return;

  // set a fixed offset for the Window on the top/left

  double left = 250; //Window's left edge, in relation to the desktop
  double top = 150; //Window's top edge, in relation to the desktop

  _prowindow = new ProWindow();
  _prowindow.WindowStartupLocation = System.Windows.WindowStartupLocation.Manual; 
  _prowindow.Left = left;
  _prowindow.Top = top;
  _prowindow.SaveWindowPosition = false;
  _prowindow.Owner = FrameworkApplication.Current.MainWindow;
  _prowindow.Closed += (o, e) => { _prowindow = null; };
  //_prowindow.Show();
  //uncomment for modal
  _prowindow.ShowDialog();
}

 

0 Kudos