Skip to content

Commit aa8f21c

Browse files
authored
Merge pull request #58 from SyncfusionExamples/WPF-910857
910857 - How to add a new button to the vertical toolbar of the WPF PdfViewer
2 parents c111e02 + 2267632 commit aa8f21c

17 files changed

+619
-0
lines changed
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{D8283AF1-7E48-4DE5-B83E-E1E1F9C88152}</ProjectGuid>
8+
<OutputType>WinExe</OutputType>
9+
<RootNamespace>AddButtonsInVerticalToolbar</RootNamespace>
10+
<AssemblyName>AddButtonsInVerticalToolbar</AssemblyName>
11+
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
12+
<FileAlignment>512</FileAlignment>
13+
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
14+
<WarningLevel>4</WarningLevel>
15+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
16+
<Deterministic>true</Deterministic>
17+
<TargetFrameworkProfile />
18+
</PropertyGroup>
19+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
20+
<PlatformTarget>AnyCPU</PlatformTarget>
21+
<DebugSymbols>true</DebugSymbols>
22+
<DebugType>full</DebugType>
23+
<Optimize>false</Optimize>
24+
<OutputPath>bin\Debug\</OutputPath>
25+
<DefineConstants>DEBUG;TRACE</DefineConstants>
26+
<ErrorReport>prompt</ErrorReport>
27+
<WarningLevel>4</WarningLevel>
28+
</PropertyGroup>
29+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
30+
<PlatformTarget>AnyCPU</PlatformTarget>
31+
<DebugType>pdbonly</DebugType>
32+
<Optimize>true</Optimize>
33+
<OutputPath>bin\Release\</OutputPath>
34+
<DefineConstants>TRACE</DefineConstants>
35+
<ErrorReport>prompt</ErrorReport>
36+
<WarningLevel>4</WarningLevel>
37+
</PropertyGroup>
38+
<ItemGroup>
39+
<PackageReference Include="Syncfusion.PdfViewer.WPF" Version="*" />
40+
<PackageReference Include="Syncfusion.Tools.WPF" Version="*" />
41+
<Reference Include="System" />
42+
<Reference Include="System.Data" />
43+
<Reference Include="System.Xml" />
44+
<Reference Include="Microsoft.CSharp" />
45+
<Reference Include="System.Core" />
46+
<Reference Include="System.Xml.Linq" />
47+
<Reference Include="System.Data.DataSetExtensions" />
48+
<Reference Include="System.Net.Http" />
49+
<Reference Include="System.Xaml">
50+
<RequiredTargetFramework>4.0</RequiredTargetFramework>
51+
</Reference>
52+
<Reference Include="WindowsBase" />
53+
<Reference Include="PresentationCore" />
54+
<Reference Include="PresentationFramework" />
55+
</ItemGroup>
56+
<ItemGroup>
57+
<ApplicationDefinition Include="App.xaml">
58+
<Generator>MSBuild:Compile</Generator>
59+
<SubType>Designer</SubType>
60+
</ApplicationDefinition>
61+
<Page Include="MainWindow.xaml">
62+
<Generator>MSBuild:Compile</Generator>
63+
<SubType>Designer</SubType>
64+
</Page>
65+
<Compile Include="App.xaml.cs">
66+
<DependentUpon>App.xaml</DependentUpon>
67+
<SubType>Code</SubType>
68+
</Compile>
69+
<Compile Include="MainWindow.xaml.cs">
70+
<DependentUpon>MainWindow.xaml</DependentUpon>
71+
<SubType>Code</SubType>
72+
</Compile>
73+
</ItemGroup>
74+
<ItemGroup>
75+
<Compile Include="PdfReport.cs" />
76+
<Compile Include="Properties\AssemblyInfo.cs">
77+
<SubType>Code</SubType>
78+
</Compile>
79+
<Compile Include="Properties\Resources.Designer.cs">
80+
<AutoGen>True</AutoGen>
81+
<DesignTime>True</DesignTime>
82+
<DependentUpon>Resources.resx</DependentUpon>
83+
</Compile>
84+
<Compile Include="Properties\Settings.Designer.cs">
85+
<AutoGen>True</AutoGen>
86+
<DependentUpon>Settings.settings</DependentUpon>
87+
<DesignTimeSharedInput>True</DesignTimeSharedInput>
88+
</Compile>
89+
<EmbeddedResource Include="Properties\Resources.resx">
90+
<Generator>ResXFileCodeGenerator</Generator>
91+
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
92+
</EmbeddedResource>
93+
<None Include="packages.config" />
94+
<None Include="Properties\Settings.settings">
95+
<Generator>SettingsSingleFileGenerator</Generator>
96+
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
97+
</None>
98+
</ItemGroup>
99+
<ItemGroup>
100+
<None Include="App.config" />
101+
</ItemGroup>
102+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
103+
</Project>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.12.35707.178 d17.12
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AddButtonsInVerticalToolbar", "AddButtonsInVerticalToolbar.csproj", "{D8283AF1-7E48-4DE5-B83E-E1E1F9C88152}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{D8283AF1-7E48-4DE5-B83E-E1E1F9C88152}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{D8283AF1-7E48-4DE5-B83E-E1E1F9C88152}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{D8283AF1-7E48-4DE5-B83E-E1E1F9C88152}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{D8283AF1-7E48-4DE5-B83E-E1E1F9C88152}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>WinExe</OutputType>
5+
<TargetFramework>net8.0-windows</TargetFramework>
6+
<Nullable>enable</Nullable>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<UseWPF>true</UseWPF>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="Syncfusion.PdfViewer.WPF" Version="*" />
13+
<PackageReference Include ="Syncfusion.Tools.WPF" Version = "*" />
14+
</ItemGroup>
15+
16+
</Project>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.12.35707.178 d17.12
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AddButtonsInVerticalToolbar_NET", "AddButtonsInVerticalToolbar_NET.csproj", "{64C42154-1D65-4D2D-80E2-81C3BF55D531}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{64C42154-1D65-4D2D-80E2-81C3BF55D531}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{64C42154-1D65-4D2D-80E2-81C3BF55D531}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{64C42154-1D65-4D2D-80E2-81C3BF55D531}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{64C42154-1D65-4D2D-80E2-81C3BF55D531}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
5+
</startup>
6+
</configuration>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Application x:Class="AddButtonsInVerticalToolbar.App"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:local="clr-namespace:AddButtonsInVerticalToolbar"
5+
StartupUri="MainWindow.xaml">
6+
<Application.Resources>
7+
8+
</Application.Resources>
9+
</Application>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Configuration;
4+
using System.Data;
5+
using System.Linq;
6+
using System.Threading.Tasks;
7+
using System.Windows;
8+
9+
namespace AddButtonsInVerticalToolbar
10+
{
11+
/// <summary>
12+
/// Interaction logic for App.xaml
13+
/// </summary>
14+
public partial class App : Application
15+
{
16+
}
17+
}
Binary file not shown.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<syncfusion:RibbonWindow x:Class="AddButtonsInVerticalToolbar.MainWindow"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5+
xmlns:syncfusion="http://schemas.syncfusion.com/wpf"
6+
ShowHelpButton="False"
7+
WindowStyle="SingleBorderWindow"
8+
Loaded="RibbonWindow_Loaded"
9+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
10+
xmlns:local="clr-namespace:AddButtonsInVerticalToolbar"
11+
xmlns:cc="clr-namespace:Syncfusion.Windows.PdfViewer;assembly=Syncfusion.PdfViewer.WPF"
12+
mc:Ignorable="d"
13+
Title="" Height="450" Width="800">
14+
<syncfusion:RibbonWindow.DataContext>
15+
<local:PdfReport />
16+
</syncfusion:RibbonWindow.DataContext>
17+
<cc:PdfViewerControl x:Name="pdfViewer"
18+
AllowDrop="True"
19+
WarnBeforeClose="False"
20+
ItemSource="{Binding Path=DocumentStream}"
21+
ZoomMode="FitWidth" />
22+
</syncfusion:RibbonWindow>
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Diagnostics;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
using System.Windows;
8+
using System.Windows.Controls;
9+
using System.Windows.Data;
10+
using System.Windows.Documents;
11+
using System.Windows.Input;
12+
using System.Windows.Media;
13+
using System.Windows.Media.Imaging;
14+
using System.Windows.Navigation;
15+
using System.Windows.Shapes;
16+
using Syncfusion.Windows.PdfViewer;
17+
using Syncfusion.Windows.Tools.Controls;
18+
19+
namespace AddButtonsInVerticalToolbar
20+
{
21+
/// <summary>
22+
/// Interaction logic for MainWindow.xaml
23+
/// </summary>
24+
public partial class MainWindow : RibbonWindow
25+
{
26+
public MainWindow()
27+
{
28+
InitializeComponent();
29+
}
30+
31+
private void RibbonWindow_Loaded(object sender, RoutedEventArgs e)
32+
{
33+
OutlinePane outlinePane = pdfViewer.Template.FindName("PART_OutlinePane", pdfViewer) as OutlinePane;
34+
35+
StackPanel stackPanel = (StackPanel)outlinePane.Template.FindName("PART_OutlineStackPanel", outlinePane);
36+
37+
Button button1 = new Button();
38+
button1.Margin = new Thickness(0, 8, 0, 8);
39+
button1.Width = 30;
40+
button1.Height = 25;
41+
button1.Content = "B1";
42+
stackPanel.Children.Add(button1);
43+
button1.Click += Button1_Click; ;
44+
45+
Button button2 = new Button();
46+
button2.Margin = new Thickness(0, 4, 0, 8);
47+
button2.Width = 30;
48+
button2.Height = 25;
49+
button2.Content = "B2";
50+
stackPanel.Children.Add(button2);
51+
button2.Click += Button2_Click; ;
52+
}
53+
54+
private void Button1_Click(object sender, RoutedEventArgs e)
55+
{
56+
string urlToOpen = "https://help.syncfusion.com/wpf/pdf-viewer/overview";
57+
Process.Start(new ProcessStartInfo
58+
{
59+
FileName = urlToOpen,
60+
UseShellExecute = true
61+
});
62+
}
63+
64+
private void Button2_Click(object sender, RoutedEventArgs e)
65+
{
66+
string urlToOpen = "https://help.syncfusion.com/wpf/pdf-viewer/getting-started";
67+
Process.Start(new ProcessStartInfo
68+
{
69+
FileName = urlToOpen,
70+
UseShellExecute = true
71+
});
72+
}
73+
}
74+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.ComponentModel;
4+
using System.IO;
5+
using System.Linq;
6+
using System.Text;
7+
using System.Threading.Tasks;
8+
9+
namespace AddButtonsInVerticalToolbar
10+
{
11+
internal class PdfReport : INotifyPropertyChanged
12+
{
13+
string filePath;
14+
private Stream docStream;
15+
public event PropertyChangedEventHandler PropertyChanged;
16+
17+
public Stream DocumentStream
18+
{
19+
get
20+
{
21+
return docStream;
22+
}
23+
set
24+
{
25+
docStream = value;
26+
OnPropertyChanged(new PropertyChangedEventArgs("DocumentStream"));
27+
}
28+
}
29+
30+
public PdfReport()
31+
{
32+
#if NETCOREAPP
33+
filePath = @"../../../Data/PDF_Succinctly.pdf";
34+
#else
35+
filePath = @"../../Data/PDF_Succinctly.pdf";
36+
#endif
37+
//Load the stream from the local system.
38+
docStream = new FileStream(filePath, FileMode.OpenOrCreate);
39+
}
40+
41+
public void OnPropertyChanged(PropertyChangedEventArgs e)
42+
{
43+
if (PropertyChanged != null)
44+
PropertyChanged(this, e);
45+
}
46+
}
47+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
using System.Reflection;
2+
using System.Resources;
3+
using System.Runtime.CompilerServices;
4+
using System.Runtime.InteropServices;
5+
using System.Windows;
6+
7+
// General Information about an assembly is controlled through the following
8+
// set of attributes. Change these attribute values to modify the information
9+
// associated with an assembly.
10+
[assembly: AssemblyDescription("")]
11+
[assembly: AssemblyCopyright("Copyright © 2025")]
12+
[assembly: AssemblyTrademark("")]
13+
[assembly: AssemblyCulture("")]
14+
15+
// Setting ComVisible to false makes the types in this assembly not visible
16+
// to COM components. If you need to access a type in this assembly from
17+
// COM, set the ComVisible attribute to true on that type.
18+
[assembly: ComVisible(false)]
19+
20+
//In order to begin building localizable applications, set
21+
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
22+
//inside a <PropertyGroup>. For example, if you are using US english
23+
//in your source files, set the <UICulture> to en-US. Then uncomment
24+
//the NeutralResourceLanguage attribute below. Update the "en-US" in
25+
//the line below to match the UICulture setting in the project file.
26+
27+
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
28+
29+
30+
[assembly: ThemeInfo(
31+
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
32+
//(used if a resource is not found in the page,
33+
// or application resource dictionaries)
34+
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
35+
//(used if a resource is not found in the page,
36+
// app, or any theme specific resource dictionaries)
37+
)]
38+
39+
40+
// Version information for an assembly consists of the following four values:
41+
//
42+
// Major Version
43+
// Minor Version
44+
// Build Number
45+
// Revision
46+
//

0 commit comments

Comments
 (0)