WPF C# Current position of Mdichild?

Asked

Viewed 47 times

1

I have implemented a MDIParent with 3 children.

I want to know where the children are but I have no access to any property since: child.position is always (0,0).

shaman I have:

<mdi:MdiContainer Name="mdiParent"/>

Code:

this.Child.Title = "ChildLoad";
this.Child.Content = this.ChildView;
this.Child.Height = 260;
this.Child.Width = 320;
this.Child.Resizable = false;
this.Child.MaximizeBox = false;
this.mdiParent.Children.Add(Child);

I can start the child at some point by adding the following code later

this.Child.Position = new Point(300, 300);

But after rotating the application, child.position is always (0,0). Even if I move the window daughter.

How do I get the son’s current position in the MdiParent?

1 answer

1

You can use the method PointToScreen to know where the MdiChild:

child.PointToScreen(new Point(0,0))

If you still have difficulty getting the position, you can try from the MdiParent:

child.TransformToAncestor(this).Transform(new Point());
  • 1

    Thank you very much for the answer, solved the problem.

  • You’re welcome, I’m glad I could help! Mark the answer as correct pf.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.