/// <summary> /// An event handler that will be fired by a click on the custom item added in <see cref="OnAddToolbarItems"/> /// </summary> /// <param name="toolbarItem">The toolbar item that was clicked</param> /// <param name="id">The id of the toolbar item</param> async void ToolbarItem_OnPress(ToolbarItem toolbarItem, string id) { var locationPromptDialog = new ContentDialog { Title = "Custom Dialog", Content = toolbarItem.Title + " was pressed.", PrimaryButtonText = "OK" }; await locationPromptDialog.ShowAsync(); }
/// <summary> /// Adds a single new toolbar item with an event handler registered to when it's clicked on /// </summary> public async Task AddToolbarItems(PdfViewer pdfView) { var view = (pdfView.GetOrCreateRenderer() as PdfViewerRenderer)?.PdfDocView; if (view == null) { return; } var toolbarItem = new ToolbarItem { Type = ToolbarItemType.Custom, Id = "id", Title = "Button", Icon = new Uri("ms-appx-web:///Assets/ToolbarIcons/status_completed.svg") }; toolbarItem.OnItemPressEvent += ToolbarItem_OnPress; var toolbarItems = view.GetToolbarItems(); toolbarItems.Add(toolbarItem); await view.SetToolbarItemsAsync(toolbarItems); }