I use this code to produce a print-preview window.
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();
}
}
But the preview window typically shows beneath the main Window. How can I get the preview to remain on top?
This code dynamically generates a Window from a simple XAML template at runtime, but that particular aspect of the code shouldn't be relevant to the problem I'm having.
Duplicate:
How do I focus a modal WPF Window when the main application window is clicked?