Hello,
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.
Xaml:
<Grid>
<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" />
</telerik:RadButton>
</Grid>
<ScrollViewer Grid.Row="1" Margin="0">
<telerik:RadPdfViewer x:Name="pdfViewer"
DocumentSource="{Binding PdfDocument}"
RenderOptions.BitmapScalingMode="HighQuality"
Height="580"
Margin="0 -2 0 0"
DocumentChanged="pdfViewer_DocumentChanged"/>
</ScrollViewer>
<telerik:RadBusyIndicator Grid.Row="1" IsBusy="{Binding IsBusy}"/>
Code-behind:
private PdfDocumentSource _pdfDocument;
public PdfDocumentSource PdfDocument
{
get => _pdfDocument;
set
{
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.