1
我使用此代碼生成打印預覽窗口。WPF:對話框在*主窗口下顯示*。如何讓它上升到頂峯?
using (XpsDocument doc = new XpsDocument(fileName, FileAccess.Read))
{
FixedDocumentSequence fds = doc.GetFixedDocumentSequence();
using (var reader = new System.Xml.XmlTextReader(new StringReader(xaml)))
{
Window preview = System.Windows.Markup.XamlReader.Load(reader) as Window;
DocumentViewer dv1 = LogicalTreeHelper.FindLogicalNode(preview, "dv1") as DocumentViewer;
dv1.Document = fds as IDocumentPaginatorSource;
dv1.FitToMaxPagesAcross(1);
// show the dialog
preview.ShowDialog();
}
}
但預覽窗口通常顯示在主窗口下方。我怎樣才能使預覽保持在最前?
該代碼在運行時從一個簡單的XAML模板動態生成一個窗口,但是該代碼的特定方面應該與我所遇到的問題無關。
重複:
How do I focus a modal WPF Window when the main application window is clicked?