How do I get WPF's DocumentViewer to release its file lock on the source XPS Document?
After showing an XPS file in the WPF DocumentViewer, and closing the DocumentViewer instance, the XPS file is locked and I cannot delete it. I need to release the lock on the XPS file so I can delete it, write another one with the same name, and optionally display that new XPS file in a new DocumentViewer instance. I need to do this in the same app instance - without having to close the app (this is a Print Preview scenario). In other words, how would I get the following code to run without throwing an exception at the "File.Delete(tempXpsFile);" statement? var tempXpsFile = @"c:\path\to