PDFViewer use ContextMenu with DocumentSource Binding

1 Answer 9 Views
PDFViewer
Benedikt
Top achievements
Rank 4
Iron
Iron
Iron
Benedikt asked on 13 Aug 2025, 08:55 AM

Hi,

I have this code, thats not working like this.

Because of the DataContext, the DocumentSource wont work, because it needs obviously a different DataContext.
But I need this DataContext for the ContextMenu to work.

Is there a way I can have both? A working context menu and also bind the DocumentSource?

Greetings
Benedikt

        <telerik:RadPdfViewerToolBar 
            Grid.Row="1"
            x:Name="pdfViewerToolBarZeichnungen" 
            Margin="0 5 0 0"
            RadPdfViewer="{Binding ElementName=pdfViewerZeichnungen}" 
            HasSaveButton="{DynamicResource SonderRechtPDFsSpeichernErlaubt}" 
            HasSignatureButton="False" 
            HasPercentComboBox="False" 
            HasPrintButton="{DynamicResource SonderRechtPDFsSpeichernErlaubt}" 
            />
        <telerik:RadPdfViewer 
            Grid.Row="2" 
            x:Name="pdfViewerZeichnungen" 
            DocumentSource="{Binding SelDatei.FilePath, Converter={StaticResource PdfDocumentSourceValueConverter}}"
            DataContext="{Binding CommandDescriptors, ElementName=pdfViewerZeichnungen}" 
            telerik:RadPdfViewerAttachedComponents.RegisterFindDialog="True" 
            telerik:RadPdfViewerAttachedComponents.RegisterContextMenu="True"
            Mode="TextSelection"
            >


1 Answer, 1 is accepted

Sort by
1
Accepted
Stenly
Telerik team
answered on 18 Aug 2025, 07:17 AM

Hello Benedikt,

To achieve this requirement, you could use the RelativeSource property of the Binding instance for the DocumentSource property to bind to the SelDatei.FilePath property. This way, the document will be correctly shown and the RadContextMenu will correctly work with the command descriptors.

The following code snippet showcases this suggestion's implementation:

<telerik:RadPdfViewer x:Name="pdfViewerZeichnungen"
                      Grid.Row="1" 
                      DocumentSource="{Binding RelativeSource={RelativeSource AncestorType=Window}, Path=DataContext.SelDatei.FilePath, Converter={StaticResource PdfDocumentSourceValueConverter}}"
                      DataContext="{Binding Path=CommandDescriptors, ElementName=pdfViewerZeichnungen}" 
                      telerik:RadPdfViewerAttachedComponents.RegisterFindDialog="True" 
                      telerik:RadPdfViewerAttachedComponents.RegisterContextMenu="True"
                      Mode="TextSelection">
</telerik:RadPdfViewer>

With this being said, could you give this suggestion a try?

Regards,
Stenly
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Benedikt
Top achievements
Rank 4
Iron
Iron
Iron
commented on 18 Aug 2025, 07:23 AM

Hi Stenly,

thank you very much, this works exactly like I wanted :D

Greetings,

Benedikt

Stenly
Telerik team
commented on 18 Aug 2025, 08:03 AM

Hello Benedikt,

I am happy to hear the suggestion was of help to you and that you took the time to let us know.

Tags
PDFViewer
Asked by
Benedikt
Top achievements
Rank 4
Iron
Iron
Iron
Answers by
Stenly
Telerik team
Share this question
or