0

I want to use the following code

Point point1 = pwImages.ElementAt(0).TransformToAncestor(Application.Current.MainWindow).Transform(new Point(0, 0));

However, Application.Current.MainWindow is not set to the window that calls this code, since the mainWindow is the window called by app.xaml. Is there an alternative I can use here besides Application.Current.MainWindow or can I reset Application.Current.MainWindow to be my current window?

David Ten
  • 113
  • 1
  • 10

1 Answers1

0

Ok so if I found out that I will need to cycle through my list of child windows to find the window I'm looking for and assign it to a variable.

 Window myWindow;
   foreach (Window objWindow in Application.Current.Windows)
        {
            if (objWindow.ToString().Equals("NameOfChildWindow"))
            {
                myWindow = objWindow;
            }
        }

I can then use objWindow as a replacement property

  Point point1 = pwImages.ElementAt(0).TransformToAncestor(myWindow).Transform(new Point(0, 0));
David Ten
  • 113
  • 1
  • 10