How to: Customize PDF Viewer Ribbon
This example demonstrates how to use ribbon customization actions to add, modify or remove elements of the PDF Viewer’s integrated Ribbon UI.
See the Lesson 3 - Customize PDF Viewer Ribbon tutorial to learn more.
Note
The complete sample project is available on GitHub at https://github.com/DevExpress-Examples/how-to-customize-pdf-viewer-toolbar-items
<Window x:Class="PdfViewerCustomization.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
xmlns:dxb="http://schemas.devexpress.com/winfx/2008/xaml/bars"
xmlns:dxpdf="http://schemas.devexpress.com/winfx/2008/xaml/pdf"
Title="MainWindow"
Height="300"
Width="525">
<dxpdf:PdfViewerControl x:Name="viewer">
<dxpdf:PdfViewerControl.CommandProvider>
<dxpdf:PdfCommandProvider>
<dxpdf:PdfCommandProvider.RibbonActions>
<dxb:RemoveAction ElementName="{x:Static dxpdf:DefaultPdfBarManagerItemNames.CommentRibbonPage}"/>
<dxb:RemoveAction ElementName="{x:Static dxpdf:DefaultPdfBarManagerItemNames.FindRibbonGroup}"/>
<dxb:RemoveAction ElementName="{x:Static dxpdf:DefaultPdfBarManagerItemNames.SaveAs}"/>
<dxb:ReplaceAction ElementName="{x:Static dxpdf:DefaultPdfBarManagerItemNames.Close}">
<dxb:BarButtonItem Content="Exit" LargeGlyph="{dx:DXImage Image=Close_32x32.png}"
Command="{Binding ElementName=viewer, Path=CloseDocumentCommand}"/>
</dxb:ReplaceAction>
<dxb:UpdateAction ElementName="{x:Static dxpdf:DefaultPdfBarManagerItemNames.MainRibbonPage}"
PropertyName="Caption" Value="caption" />
<dxb:InsertAction Index="1" ContainerName="{x:Static dxpdf:DefaultPdfBarManagerItemNames.FileRibbonGroup}">
<dxb:BarButtonItem Content="Save" LargeGlyph="{dx:DXImage Image=SaveAs_32x32.png}"
Command="{Binding ElementName=viewer, Path=SaveAsCommand}"/>
</dxb:InsertAction>
</dxpdf:PdfCommandProvider.RibbonActions>
</dxpdf:PdfCommandProvider>
</dxpdf:PdfViewerControl.CommandProvider>
</dxpdf:PdfViewerControl>
</Window>