/// <summary> /// 第二次进来,会移除以前的 /// </summary> /// <param name="mapGrid"></param> public static void AddParentGrid(Grid mapGrid) { if (mapGrid.Children.Count > 0) { mapGrid.Children.RemoveRange(0, mapGrid.Children.Count); } WindowsFormsHost windowsFormsHost = new WindowsFormsHost(); MapForm mapForm = MapForm.GetInstance(); mapForm.Width = (int)mapGrid.ActualWidth; mapForm.Height = (int)mapGrid.ActualHeight; windowsFormsHost.Width = mapGrid.Width; windowsFormsHost.Height = mapGrid.Height; mapForm.TopLevel = false; windowsFormsHost.Child = mapForm; mapGrid.Children.Add(windowsFormsHost); }
private void UserControl_SizeChanged(object sender, SizeChangedEventArgs e) { MapForm.AddParentGrid(mapGrid); }
private MapFormCustom() { InitializeComponent(); MapForm.AddParentGrid(mapGrid); }