WPF: can a page own a WindowsForms form

57 views Asked by At

I have a wpf application where several pages are displayed inside a window (using uniformgrid with dynamically added frames). The pages get rearranged inside the window when special events are called. The problem is: sometimes I have to call a System.Windows.Forms form inside a page. I want this form to be displayed on top of the page (overlaying the page). I already calculated the position:

StatusForm frm = new StatusForm (m_object, parameters);
frm.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
Point topleftPageCoord = this.PointToScreen(new Point(0, 0));// get topleft coordinates of the page
int x = (int)topleftPageCoord.X + ((int)this.ActualWidth - frm.Size.Width) / 2;
int y = (int)topleftPageCoord.Y + ((int)this.ActualHeight - frm.Size.Height) / 2;
frm.Location = new System.Drawing.Point(x, y);
frm.ShowDialog();
if (frm.Result != "") do something;

but when my whole window gets rearranged the form is (of course) still at this old position. Is there a way to call the form with the page as owner? So that the form is somehow connected to the page and automatically moved when the page is moved?

0

There are 0 answers