How can I ensure my code is called when an Event happens in CompleteReader sample of WinRT?


I’m using PDFNet for Windows Store Apps. Using the samples included with this variant of PDFNet, the ToolManager class raises the event RaiseAnnotationAddedEvent when an annotation is added. How can we call our own function when that event is raised?


The ToolManager class raises these events when an annotation is added by use of the tools. So, if you are using a PDFViewCtrl and a ToolManager for annotating, then simply register for the event:

ToolManager _ToolManager = new ToolManager(_PDFViewCtrl); _ToolManager.AnnotationAdded += ToolManagerAnnotationAdded;

Where ToolManagerAnnotationAdded is the following function:

void ToolManagerAnnotationAdded(IAnnot annotation) { // do your stuff }

You can find similar code in CompleteReader. For example, this happens inside the ActivateTab function in the file ViewModels.View.ViewerViewModel.cs.