Toolbar annotation tool changed event

Hello,

I recently started using the Syncfusion PdfViewer control in a WPF application. It's a simple app that allows you to open a pdf file and using a custom toolbar (as can be seen below) allows the user to insert free text annotations with a pre-set text/size/color.


This new "annotation tool" can be toggled on/off with the "@" button. This way the user can continue clicking on the pdf to insert text boxes. However, I would like to disable the tool when the user selects another annotation tool (pen/eraser/shape/etc.) from the pdfViewer toolbar.

Can an event be added to the control that is being raised when a button on the pdfViewer toolbar is clicked, like ToolbarSelectionChangedEvent?



3 Replies 1 reply marked as answer

VS Vikas Sekar Syncfusion Team December 2, 2021 06:22 PM UTC

Hi Wouter, 
 
Based on your requirement, we understood that you want to hide your custom toolbar when any other annotation buttons are selected. So that you need notification when the annotation is selected in the standard toolbar.  
 
Currently, we do not have provision for this. However, we can achieve this by accessing the annotation button using its template name and identify when it is selected, using its built-in functionalities as shown on the following code. 
 
Code Snippet: 
 
            DocumentToolbar toolbar = pdfViewer.Template.FindName("PART_Toolbar", pdfViewer)    as DocumentToolbar; 
            System.Windows.Controls.Primitives.ToggleButton stickyButton = (System.Windows.Controls.Primitives.ToggleButton)toolbar.Template.FindName("PART_StickyNote", toolbar); 
            stickyButton.Checked += Button_Checked; 
 
private void Button_Checked(object sender, RoutedEventArgs e) 
        { 
            //The toggle button that you use to add free text.  
            Button.IsChecked= false; 
        } 
 
The sample can be downloaded from the below link, 
 
You can find more details about the template names of the toolbar items from the following UG link: 
 
Please let us know if you need further assistance in this. 
 
Regards, 
Vikas 


Marked as answer

WV Wouter van der Post replied to Vikas Sekar December 2, 2021 08:01 PM UTC

Hello Vikas,


Thanks for the suggested solution, I've implemented this and it does exactly what I need. Thanks!




VS Vikas Sekar Syncfusion Team December 3, 2021 03:31 PM UTC

Hi Wouter,  
 
We are glad to know that the solution which we provided fulfill your requirement.  
 
Regards, 
Vikas 


Loader.
Up arrow icon