There is a KB : KB5022083 Change in how WPF-based applications render XPS documents
WPF DocumentViewer doesn't display images
Yannick Lalbatry
21
Reputation points
I have an XPS file, originaly created from WPF with 2 controls, one TextBox and one Image.
I can open the XPS file in the Windows Viewer without problem.
When running this code, the image is not displayed, what is wrong?
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
var xps = new XpsDocument("printPreview.xps", FileAccess.Read);
viewer.Document = xps.GetFixedDocumentSequence();
xps.Close();
}
}
<Window x:Class="XpsTest.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:XpsTest"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<DocumentViewer Name="viewer"/>
</Grid>
</Window>
Developer technologies XAML
859 questions
Accepted answer
5 additional answers
Sort by: Most helpful
-
fdelvalle 1 Reputation point
2022-12-28T17:17:31.76+00:00 Thank you, it works for me too, but the command you wrote has a typo:
reg add "HKLM\SOFTWARE\Microsoft.NET\Framework\Windows Presentation Foundation\XPSAllowedTypes" /v "DisableDec2022Patch" /t REG_SZ /d "*" /reg:64