Skip to content

Commit cd37e08

Browse files
Adding changes
1 parent c7df47a commit cd37e08

File tree

2 files changed

+25
-15
lines changed

2 files changed

+25
-15
lines changed

Styles/StylingToolbarItem/README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ This namespace enables access to the PDF Viewer control.
164164
pdfViewer.DocumentSource = DocumentStream;
165165
```
166166

167-
168167
### 9. Matching semantics of the custom toolbar item with default toolbar item
169168

170169
To match the text color of newly added toolbar item with that of default toolbar item in the toolbar, set the color of the [TextColor](https://learn.microsoft.com/en-us/dotnet/api/microsoft.maui.controls.button.textcolor?view=net-maui-9.0) for the button as that of the default toolbar item using the [SetAppThemeColor](https://learn.microsoft.com/en-us/dotnet/api/microsoft.maui.controls.bindableobjectextensions.setappthemecolor?view=net-maui-9.0) method. Refer to the below code example.
@@ -181,8 +180,6 @@ To match the text color of newly added toolbar item with that of default toolbar
181180
BackgroundColor = Colors.Transparent, // Set background for the button
182181
BorderColor = Colors.Transparent, // Set border color for the button
183182
CornerRadius = 5, // Set corner radius of the button
184-
Opacity = 1,
185-
IsEnabled = true
186183
};
187184

188185
//Set color based on theme.

Styles/StylingToolbarItem/View/PDFViewerPage.xaml.cs

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,34 +15,47 @@ public PDFViewerPage()
1515
// Assigning stream to "DocumentSource" property.
1616
PdfViewer.DocumentSource = documentStream;
1717

18-
// Calling "AddFileOperationsToolbarItems" for to add save and open options toolbar item in toolbar
18+
// Calling "AddFileOperationsToolbarItems" for to add save and open options toolbar item in toolbar.
1919
AddFileOperationsToolbarItem();
20+
21+
// Wiring "DocumentLoaded" event to enable the button.
22+
PdfViewer.DocumentLoaded += PdfViewer_DocumentLoaded;
23+
}
24+
25+
private void PdfViewer_DocumentLoaded(object? sender, EventArgs? e)
26+
{
27+
if (fileOpenButton != null)
28+
{
29+
// Enable the fileOpenButton to allow user interaction.
30+
fileOpenButton.IsEnabled = true;
31+
fileOpenButton.Opacity = 1; // Set the opacity of the button.
32+
}
2033
}
2134

2235
void AddFileOperationsToolbarItem()
2336
{
24-
// Create new open button
37+
// Create new open button.
2538
fileOpenButton = new Button
2639
{
27-
Text = "\ue712", // Set button text
28-
FontSize = 24, // Set button text font size
29-
FontFamily = "MauiMaterialAssets", // Set button text font family
30-
BackgroundColor = Colors.Transparent, // Set background for the button
31-
BorderColor = Colors.Transparent, // Set border color for the button
32-
CornerRadius = 5, // Set corner radius of the button
33-
Opacity = 1,
34-
IsEnabled = true
40+
Text = "\ue712", // Set button text.
41+
FontSize = 24, // Set button text font size.
42+
FontFamily = "MauiMaterialAssets", // Set button text font family.
43+
BackgroundColor = Colors.Transparent, // Set background for the button.
44+
BorderColor = Colors.Transparent, // Set border color for the button.
45+
CornerRadius = 5, // Set corner radius of the button.
46+
Opacity = 0.5, // Set opacity of the button.
47+
IsEnabled = false, // Disable the button.
3548
};
3649

37-
//Subscription of click event for the open file button
50+
//Subscription of click event for the open file button.
3851
fileOpenButton.Clicked += FileOpenButton_Clicked;
3952

4053
//Set color based on theme.
4154
fileOpenButton.SetAppThemeColor(Button.TextColorProperty,
4255
Color.FromArgb("#49454F"),
4356
Color.FromArgb("#CAC4D0"));
4457

45-
// Set the tooltip text on hover
58+
// Set the tooltip text.
4659
ToolTipProperties.SetText(fileOpenButton, "OpenFile");
4760

4861
#if !WINDOWS && !MACCATALYST

0 commit comments

Comments
 (0)