popup支持设置大小

This commit is contained in:
艾竹
2023-05-01 23:07:19 +08:00
parent 508de7a7d9
commit 6fa78893ee
8 changed files with 30 additions and 2 deletions

View File

@@ -18,5 +18,12 @@ namespace AIStudio.Wpf.DiagramDesigner.Services
/// <param name="dataContextForPopup">Object state to associate with the dialog</param>
/// <returns>True/False if UI is displayed.</returns>
bool? ShowDialog(object dataContextForPopup);
/// <summary>
/// This method displays a modal dialog associated with the given key.
/// </summary>
/// <param name="dataContextForPopup">Object state to associate with the dialog</param>
/// <returns>True/False if UI is displayed.</returns>
bool? ShowDialog(object dataContextForPopup, double width, double height);
}
}

View File

@@ -22,6 +22,20 @@ namespace AIStudio.Wpf.DiagramDesigner.Services
return false;
}
public bool? ShowDialog(object dataContextForPopup, double width, double height)
{
PopupWindow win = new PopupWindow();
win.SizeToContent = SizeToContent.Manual;
win.Width = width;
win.Height = height;
win.DataContext = dataContextForPopup;
win.Owner = Application.Current.MainWindow;
if (win != null)
return win.ShowDialog();
return false;
}
#endregion