Telerik WPF PdfDocumentSource not updating after save

1 Answer 28 Views
Top achievements
Rank 1
Robert asked on 12 May 2021, 10:01 PM


I've built an application that uses .Net Core 3.1 and the Prism MVVM package.

I have a RadPdfViewerToolBar and a RadPdfViewer on the view. I generate documents and render the output using the following logic. This logic works fine repeatedly for every document I generate. However, if I click the Save button in the RadPdfViewerToolBar, the RadPdfViewer stops updating. I have to restart the program to get the controls working again.


	<telerik:RadPdfViewerToolBar x:Name="pdfViewerToolbar" RadPdfViewer="{Binding ElementName=pdfViewer, Mode=OneTime}" Margin="0" FocusManager.IsFocusScope="False"
				HasClockwiseButton="False" HasCounterclockwiseButton="False" HasOpenButton="True" HasSaveButton="True" HasSignatureButton="False" />
	<telerik:RadButton Command="{Binding CommandCopy}" Margin="0 -4 8 0" Padding="0" Height="26" Width="24" HorizontalAlignment="Right">
		<Image Margin="0" Height="16" Width="16" Source="{telerik:RadGlyph Glyph={StaticResource GlyphCopy}, Foreground=Black}" HorizontalAlignment="Left" />
<ScrollViewer Grid.Row="1" Margin="0">
	<telerik:RadPdfViewer x:Name="pdfViewer"
			DocumentSource="{Binding PdfDocument}"
			Margin="0 -2 0 0"
<telerik:RadBusyIndicator Grid.Row="1" IsBusy="{Binding IsBusy}"/>


private PdfDocumentSource _pdfDocument;
public PdfDocumentSource PdfDocument
	get => _pdfDocument;
		SetProperty(ref _pdfDocument, value);


protected override async Task LoadViewModel() { IsBusy = true; PdfDocument = null; await Task.Delay(10); try { var sc = System.Threading.SynchronizationContext.Current; System.Threading.ThreadPool.QueueUserWorkItem(_ => { PdfDocumentSource documentSource = null; RadFixedDocument document = CreateDocument(); if (document != null) { MemoryStream stream = new MemoryStream(); PdfFormatProvider provider = new PdfFormatProvider(); provider.Export(document, stream); stream.Position = 0; documentSource = new PdfDocumentSource(stream); } sc.Post(delegate { PdfDocument = documentSource; IsBusy = false; }, null); }); } catch (Exception ex) { ShowDialog($"{Constants.EXCEPTION} in LoadViewModel: {ex.Message}"); IsBusy = false; } }


Does anyone have a suggestion on how I might resolve this issue? Is it a bug in the RadPdfViewer?

Any help would be greatly appreciated.

1 Answer, 1 is accepted

Sort by
Telerik team
answered on 14 May 2021, 09:18 AM

Hi Robert,

Thank you for sharing the code. I was able to reproduce the observed behavior. After the document is saved the new document is directly loaded by setting the DocumentSource which resets the binding. To solve this I would recommend using your own commands for the Save and Open buttons and handle the operations manually in your view model. This can be done by replacing the toolbar with editable XAML and changing the commands:  WPF PdfViewer | Default UI.

I hope this helps. Should you have any other questions do not hesitate to ask.

Progress Telerik

Тhe web is about to get a bit better! 

The Progress Hack-For-Good Challenge has started. Learn how to enter and make the web a worthier place:

Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question