| layout | post |
|---|---|
| title | Getting started with WPF Markdown Viewer control | Syncfusion |
| description | Learn how to get started with Syncfusion® WPF SfMarkdownViewer control and explore its capabilities for rendering Markdown content. |
| platform | wpf |
| control | SfMarkdownViewer |
| documentation | ug |
| keywords | wpf markdownviewer, syncfusion markdownviewer wpf, markdown viewer wpf, wpf markdown rendering, sfmarkdownviewer wpf, wpf markdown control, markdown rendering wpf, wpf markdown getting started |
This section provides a step-by-step guide to integrate and use the SfMarkdownViewer control in your WPF applications.
Refer to the Control Dependencies section to get the list of assemblies or NuGet package that needs to be added as a reference to use the control in any application.
Refer to this documentation to find more details about installing nuget packages in a WPF application.
- Go to File > New > Project and choose the WPF App template.
- Name the project and choose a location. Then click Next.
- Select the .NET framework version and click Create.
- In Solution Explorer, right-click the project and choose Manage NuGet Packages.
- Search for Syncfusion.SfMarkdownViewer.Wpf and install the latest version.
- Ensure the necessary dependencies are installed correctly, and the project is restored.
To add the SfMarkdownViewer manually in XAML, follow these steps:
-
Create a new WPF project in Visual Studio.
-
Add the following required assembly references to the project:
- Syncfusion.SfMarkdownViewer.WPF
- Syncfusion.Markdown
- Syncfusion.Shared.WPF
-
Import the control namespace
Syncfusion.UI.Xaml.Markdownin XAML, and declare theSfMarkdownViewerin XAML page.
{% tabs %} {% highlight xaml %}
<markdown:SfMarkdownViewer />
{% endhighlight %} {% endtabs %}
To add the SfMarkdownViewer manually in C#, follow these steps:
-
Create a new WPF project in Visual Studio.
-
Add the following required assembly references to the project:
- Syncfusion.SfMarkdownViewer.WPF
- Syncfusion.Markdown
- Syncfusion.Shared.WPF
-
Import the control namespace
Syncfusion.UI.Xaml.Markdownin C#, and add theSfMarkdownViewerin C# page.
{% tabs %} {% highlight C# %}
using Syncfusion.UI.Xaml.Markdown;
namespace MarkdownViewerGettingStarted { public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); // Creating an instance of the SfMarkdownViewer control SfMarkdownViewer markdownViewer = new SfMarkdownViewer(); this.Content = markdownViewer;
}
}
}
{% endhighlight %} {% endtabs %}
The Source property is used to provide Markdown content to the control. The Source accepts raw Markdown text, file paths, or HTTP/HTTPS URLs.
{% tabs %} {% highlight xaml %}
markdown:SfMarkdownViewer markdown:SfMarkdownViewer.Source <system:String xml:space="preserve"> <![CDATA[
The MarkdownViewer control is used to render and preview Markdown files. It converts markdown syntax into a clean, readable format and supports elements such as headings, lists, code blocks, tables, and other common markdown structures.
Used for the main title or top-level heading in a Markdown document.
Used to define major sections within your Markdown content.
]]>
</system:String>
</markdown:SfMarkdownViewer.Source>
</markdown:SfMarkdownViewer>
{% endhighlight %}
{% highlight C# %}
public partial class MainWindow : Window { private const string markdownContent = @"
The MarkdownViewer control is used to render and preview Markdown files. It converts markdown syntax into a clean, readable format and supports elements such as headings, lists, code blocks, tables, and other common markdown structures.
Used for the main title or top-level heading in a Markdown document.
Used to define major sections within your Markdown content.
public MainWindow()
{
InitializeComponent();
SfMarkdownViewer markdownViewer = new SfMarkdownViewer();
markdownViewer.Source = markdownContent;
this.Content = markdownViewer;
}
}
{% endhighlight %} {% endtabs %}