|
private void
Window_Loaded(object sender, RoutedEventArgs e)
{
//Get the instance of the toolbar using its template
name.
DocumentToolbar toolbar = pdfViewer.Template.FindName("PART_Toolbar",
pdfViewer) as
DocumentToolbar;
//Get the instance of the file menu button using its
template name.
ToggleButton FileButton = (ToggleButton)toolbar.Template.FindName("PART_FileToggleButton", toolbar);
//Get the instance of the file menu button context menu
and the item collection.
ContextMenu FileContextMenu =
FileButton.ContextMenu;
foreach (MenuItem
FileMenuItem in FileContextMenu.Items)
{
//Get the instance of the save as menu item using its
template name and disable its visibility.
if (FileMenuItem.Name == "PART_SaveAsMenuItem")
FileMenuItem.Visibility =
Visibility.Collapsed;
//Get the instance of the print menu item using its
template name and disable its visibility.
if (FileMenuItem.Name == "PART_PrintMenuItem")
FileMenuItem.Visibility =
Visibility.Collapsed;
}
}
|