Skip to content

Commit 53135b5

Browse files
Adding changes
1 parent 9cc79ee commit 53135b5

File tree

2 files changed

+58
-2
lines changed

2 files changed

+58
-2
lines changed

MultiTabbedPDFViewer/README.md

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,61 @@ In the MainPage constructor, set the [ZoomMode](https://help.syncfusion.com/cr/m
8989
pdfViewer2.ZoomMode = ZoomMode.FitToWidth;
9090
```
9191

92-
### 5. Loading the pdfViewer in different tabs using the SfTabView Loaded event handler.
92+
### 5. PdfViewerViewModel class
93+
94+
**C#:**
95+
96+
```csharp
97+
public class PdfViewerViewModel : INotifyPropertyChanged
98+
{
99+
private ObservableCollection<Stream>? _pdfDocuments;
100+
101+
/// <summary>
102+
/// Constructor of the view model class
103+
/// </summary>
104+
public PdfViewerViewModel()
105+
{
106+
// Initialize the collection
107+
PDFDocuments = new ObservableCollection<Stream>();
108+
109+
//Accessing the PDF document that is added as embedded resource as stream.
110+
Stream? documentSource = typeof(App).GetTypeInfo().Assembly.GetManifestResourceStream("MultiTabbedPDFViewer.Assets.PDF_Succinctly.pdf");
111+
Stream? documentSource1 = typeof(App).GetTypeInfo().Assembly.GetManifestResourceStream("MultiTabbedPDFViewer.Assets.form_document.pdf");
112+
Stream? documentSource2 = typeof(App).GetTypeInfo().Assembly.GetManifestResourceStream("MultiTabbedPDFViewer.Assets.Annotations.pdf");
113+
// Add the PDF streams to the collection if they are successfully retrieved
114+
if (documentSource != null)
115+
PDFDocuments.Add(documentSource);
116+
if (documentSource1 != null)
117+
PDFDocuments.Add(documentSource1);
118+
if (documentSource2 != null)
119+
PDFDocuments.Add(documentSource2);
120+
}
121+
122+
/// <summary>
123+
/// Collection of PDF document streams.
124+
/// </summary>
125+
public ObservableCollection<Stream>? PDFDocuments
126+
{
127+
get => _pdfDocuments;
128+
set
129+
{
130+
_pdfDocuments = value;
131+
OnPropertyChanged(nameof(PDFDocuments));
132+
}
133+
}
134+
135+
/// <summary>
136+
/// An event to detect the change in the value of a property.
137+
/// </summary>
138+
public event PropertyChangedEventHandler? PropertyChanged;
139+
protected virtual void OnPropertyChanged(string propertyName)
140+
{
141+
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
142+
}
143+
}
144+
```
145+
146+
### 6. Loading the pdfViewer in different tabs using the SfTabView Loaded event handler.
93147

94148
In the SfTabView `Loaded` event handler, evaluate the header text of each SfTabItem. Based on the header, assign the appropriate PDF stream to the [DocumentSource](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_DocumentSource) property of the corresponding SfPdfViewer instance. Then, set that PdfViewer instance as the content of the respective SfTabItem
95149

MultiTabbedPDFViewer/ViewModel/PdfViewerViewModel.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Collections.ObjectModel;
22
using System.ComponentModel;
33
using System.Reflection;
4+
using static Android.Hardware.Camera;
45

56
namespace MultiTabbedPDFViewer
67
{
@@ -20,6 +21,7 @@ public PdfViewerViewModel()
2021
Stream? documentSource = typeof(App).GetTypeInfo().Assembly.GetManifestResourceStream("MultiTabbedPDFViewer.Assets.PDF_Succinctly.pdf");
2122
Stream? documentSource1 = typeof(App).GetTypeInfo().Assembly.GetManifestResourceStream("MultiTabbedPDFViewer.Assets.form_document.pdf");
2223
Stream? documentSource2 = typeof(App).GetTypeInfo().Assembly.GetManifestResourceStream("MultiTabbedPDFViewer.Assets.Annotations.pdf");
24+
// Add the PDF streams to the collection if they are successfully retrieved
2325
if (documentSource != null)
2426
PDFDocuments.Add(documentSource);
2527
if (documentSource1 != null)
@@ -29,7 +31,7 @@ public PdfViewerViewModel()
2931
}
3032

3133
/// <summary>
32-
/// Collection of PDF document streams for the ListView
34+
/// Collection of PDF document streams.
3335
/// </summary>
3436
public ObservableCollection<Stream>? PDFDocuments
3537
{

0 commit comments

Comments
 (0)