We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Using PdfViewer in combination with dockingManager results in System.NullReferenceException

Hi,

I am using PdfViewer and do some modification on the toolbar (adding custom stamps). Everything works fine so far.

But after adding a dockingManager to my ChromelessWindow I get a System.NullReferenceException while the toolbar is modified by my code.

Dim toolbar As DocumentToolbar = TryCast(pdfViewer.Template.FindName("PART_Toolbar", pdfViewer), DocumentToolbar)
Dim stampButton As ToggleButton = CType(toolbar.Template.FindName("PART_Stamp", toolbar), ToggleButton)
Dim customMenuItem As MenuItem = CType(stampButton.ContextMenu.Items(1), MenuItem)


The exceptions is because toolbar is nothing in line 2.

The System.NullReferenceException occurs ONLY if I NOT call dockingManager.LoadDockState()​.
If  dockingManager.LoadDockState() ​is called, it works fine.


What I am doing wrong?
Thank you for your help.

Marco


1 Reply

KG Krithika Ganesan Syncfusion Team October 27, 2022 06:37 AM

Hi Marco,

 

Thank you for contacting Syncfusion Support. 

 

We are unable to reproduce the issue in our side. We have attached a sample which we have tried for your reference. Please let us know whether you are still facing the issue in the attached sample or please modify the sample and share it with us. It will help us to reproduce the issue on our end and assist you with a better solution. 

 

Note:

PdfViewer’s toolbar should be accessed or modify in PdfViewerLoaded event, as the toolbar will be initialized before it.  

 

Regards,

Krithika


Attachment: PdfViewerWPF_1ce90828.zip

Loader.
Live Chat Icon For mobile
Up arrow icon