Skip to content

Commit b58210e

Browse files
Merge pull request #3533 from syncfusion-content/markdown-viewer-ug
968298 : Prepare UG Document for .NET MAUI Markdown Viewer
2 parents 1edead7 + 7d9d830 commit b58210e

10 files changed

+770
-0
lines changed

MAUI/MarkdownViewer/Appearance.md

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
---
2+
layout: post
3+
title: Customize Appearance in .NET MAUI MarkdownViewer | Syncfusion
4+
description: Learn how to style and customize the appearance of Markdown content using the MarkdownStyleSettings class in the Syncfusion .NET MAUI MarkdownViewer control.
5+
platform: MAUI
6+
control: SfMarkdownViewer
7+
documentation: ug
8+
---
9+
10+
# Customize Appearance in .NET MAUI SfMarkdownViewer
11+
12+
The [SfMarkdownViewer]() control in .NET MAUI provides a powerful styling system through the `MarkdownStyleSettings` class. This allows developers to customize the visual presentation of Markdown content with precision and flexibility.
13+
14+
## Key Features
15+
16+
- **Granular Styling**: Customize font sizes and colors for headings, body text, and tables.
17+
- **Custom CSS Support**: Apply advanced styling using raw CSS rules.
18+
- **Two-Layer Styling System**: Merge base styles with custom CSS for full control.
19+
- **Reset Functionality**: Revert all styles to default with a single method call.
20+
21+
## Use Cases
22+
23+
- Match Markdown content appearance with your app’s theme.
24+
- Improve readability with tailored font sizes and spacing.
25+
- Highlight specific Markdown elements like tables or code blocks.
26+
- Apply branding styles using custom CSS.
27+
28+
## Customization with MarkdownStyleSettings
29+
30+
The appearance of headings and body content in SfMarkdownViewer can be customized using the MarkdownStyleSettings class.
31+
32+
[H1FontSize](), [H2FontSize](), [H3FontSize]() – Gets or sets the font size for H1, H2, and H3 heading elements respectively.
33+
34+
[H1Color](), [H2Color](), [H3Color]() – Gets or sets the text color for H1, H2, and H3 heading elements respectively.
35+
36+
[BodyFontSize]() – Gets or sets the font size for regular paragraph text.
37+
38+
[BodyTextColor]() – Gets or sets the text color for body content.
39+
40+
[TableHeaderFontSize](), [TableDataFontSize]() – Gets or sets the font size for table headers and table content respectively.
41+
42+
[TableHeaderTextColor](), [TableDataTextColor]() – Gets or sets the text color for table headers and table content respectively.
43+
44+
[TableBackground]() – Gets or sets the background color for the entire table area.
45+
46+
[CssStyleRules]() – Gets or sets raw CSS styles to override or extend default Markdown rendering behavior.
47+
48+
{% tabs %}
49+
{% highlight xaml %}
50+
51+
<ContentPage>
52+
. . .
53+
<markdown:SfMarkdownViewer Source={Binding MarkdownContent}>
54+
<markdown:SfMarkdownViewer.Settings>
55+
<markdown:MarkdownStyleSettings H1FontSize = "32px"
56+
H1Color = "#8352FB"
57+
H2Color = "#9971FB"
58+
H3Color = "#A98AF7"
59+
BodyFontSize = "16px"
60+
BodyTextColor = "#2C3E50"
61+
TableBackground = "#FFE2ED"
62+
TableHeaderTextColor = "HotPink">
63+
</markdown:MarkdownStyleSettings>
64+
</markdown:SfMarkdownViewer.Settings>
65+
</markdown:SfMarkdownViewer>
66+
. . .
67+
</ContentPage>
68+
69+
{% endhighlight %}
70+
71+
{% highlight C# %}
72+
73+
public partial class MainPage : ContentPage
74+
{
75+
. . .
76+
77+
public MainPage()
78+
{
79+
InitializeComponent();
80+
81+
SfMarkdownViewer markdownViewer = new SfMarkdownViewer();
82+
markdownViewer.Source = MarkdownContent;
83+
MarkdownViewer.Settings = new MarkdownStyleSettings()
84+
{
85+
H1FontSize = "32px",
86+
H1Color = "#8352FB",
87+
H2Color = "#9971FB",
88+
H3Color = "#A98AF7",
89+
BodyFontSize = "16px",
90+
BodyTextColor = "#2C3E50",
91+
TableBackground = "#FFE2ED",
92+
TableHeaderTextColor = "HotPink"
93+
};
94+
95+
Content = markdownViewer;
96+
}
97+
}
98+
99+
{% endhighlight %}
100+
{% endtabs %}
101+
102+
![Sample markdown content appearance customization](images/maui-markdown-viewer-appearance.png)
103+
104+
With [MarkdownStyleSettings](), you gain full control over how Markdown content looks in your .NET MAUI app—whether you're building a documentation viewer, a note-taking app, or a styled content portal.
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
---
2+
layout: post
3+
title: Retrieve Content in .NET MAUI MarkdownViewer | Syncfusion
4+
description: Learn how to retrieve and transform Markdown content using built-in methods in the Syncfusion .NET MAUI MarkdownViewer control.
5+
platform: MAUI
6+
control: SfMarkdownViewer
7+
documentation: ug
8+
---
9+
10+
# Retrieve Content Programmatically in .NET MAUI SfMarkdownViewer
11+
12+
The [SfMarkdownViewer]() control provides built-in methods to retrieve and transform Markdown content programmatically. These methods allow developers to access the raw Markdown, convert it to HTML, or extract plain text without formatting.
13+
14+
## GetMarkdownText()
15+
16+
Retrieves the raw Markdown content currently assigned to the `Source` property of the [SfMarkdownViewer]() control.
17+
18+
{% tabs %}
19+
{% highlight C# hl_lines="12" %}
20+
21+
public partial class MainPage : ContentPage
22+
{
23+
public MainPage()
24+
{
25+
InitializeComponent();
26+
SfMarkdownViewer markdownViewer = new SfMarkdownViewer();
27+
markdownViewer.Source = "Welcome to **Markdown Viewer**!";
28+
Content = markdownViewer;
29+
}
30+
. . .
31+
32+
string markdown = MarkdownViewer.GetMarkdown();
33+
}
34+
35+
{% endhighlight %}
36+
{% endtabs %}
37+
38+
## GetHtml()
39+
40+
Converts the Markdown content of the SfMarkdownViewer control into HTML format and provides the result as a string.
41+
42+
{% tabs %}
43+
{% highlight C# hl_lines="12" %}
44+
45+
public partial class MainPage : ContentPage
46+
{
47+
public MainPage()
48+
{
49+
InitializeComponent();
50+
SfMarkdownViewer markdownViewer = new SfMarkdownViewer();
51+
markdownViewer.Source = "Welcome to **Markdown Viewer**!";
52+
Content = markdownViewer;
53+
}
54+
. . .
55+
56+
string html = MarkdownViewer.GetHtml();
57+
}
58+
59+
{% endhighlight %}
60+
{% endtabs %}
61+
62+
## GetText()
63+
64+
Extracts the plain text content from the Markdown assigned to the `SfMarkdownViewer` control, removing all Markdown formatting such as headings, emphasis, links, and code blocks.
65+
66+
{% tabs %}
67+
{% highlight C# hl_lines="12" %}
68+
69+
public partial class MainPage : ContentPage
70+
{
71+
public MainPage()
72+
{
73+
InitializeComponent();
74+
SfMarkdownViewer markdownViewer = new SfMarkdownViewer();
75+
markdownViewer.Source = "Welcome to **Markdown Viewer**!";
76+
Content = markdownViewer;
77+
}
78+
. . .
79+
80+
string text = markdownViewer.GetText();
81+
}
82+
83+
{% endhighlight %}
84+
{% endtabs %}

0 commit comments

Comments
 (0)