Hi,
I am using this vb.net code to add a custom stamp durch start of my application.
This will just add an empty stamp (cannot see the image in the toolbar, just an empty element). Clicking on thes empty stamp will result in a System.NullReferenceException.
Here is my code:
Private Sub pdfViewer_Loaded(sender As Object, e As RoutedEventArgs) Handles pdfViewer.Loaded
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)
'Create the instance of the image
Dim image As System.Windows.Controls.Image = New System.Windows.Controls.Image()
Dim BitmapImage As BitmapImage = New BitmapImage()
BitmapImage.BeginInit()
BitmapImage.CacheOption = BitmapCacheOption.Default
BitmapImage.UriSource = New Uri("image.png", UriKind.RelativeOrAbsolute)
BitmapImage.EndInit()
'Create the viewbox And the image.
Dim viewbox As Viewbox = New Viewbox()
viewbox.Child = image
Dim _grid As New System.Windows.Controls.Grid()
_grid.Children.Add(viewbox)
customMenuItem.Items.Add(_grid)
End Sub
What I am doing wrong?
Thank you in advance. Marco