我有一个WPF窗口,它产生一个自定义用户控件
owner = Window.GetWindow(placementTarget);
form = new Form();
form.Opacity = owner.Opacity;
form.ShowInTaskbar = false;
form.FormBorderStyle = FormBorderStyle.None;
System.Drawing.Size size = new System.Drawing.Size(Convert.ToInt32(placementTarget.ActualWidth), Convert.ToInt32(placementTarget.ActualHeight));
form.ClientSize = size;
webBrowser.Dock = DockStyle.Fill;
form.Controls.Add(webBrowser);
Cursor.Hide();
Point location = placementTarget.TransformToAncestor(owner).Transform(new Point(0, 0));
form.Left = Convert.ToInt32(location.X + owner.Left);
form.Top = Convert.ToInt32(location.Y + owner.Top);
DependencyPropertyDescriptor descriptor = DependencyPropertyDescriptor.FromProperty(UIElement.OpacityProperty, typeof(Window));
descriptor.AddValueChanged(owner, delegate { form.Opacity = owner.Opacity; });
这会显示表单,如果我将表单的left属性移动到负值,我可以看到它,这样我的主窗口就不会覆盖它。
出于某种原因,我似乎无法将此表单显示在窗口的顶部。有什么想法吗?
干杯。