windowsforms-devexpress-dot-utils-dot-html-dot-htmltemplate-659e148d.md
Gets or sets the template’s HTML markup used to build a control’s UI.
Namespace : DevExpress.Utils.Html
Assembly : DevExpress.Utils.v25.2.dll
NuGet Packages : DevExpress.Utils, DevExpress.Wpf.Core
[DefaultValue("")]
public string Template { get; set; }
<DefaultValue("")>
Public Property Template As String
| Type | Default | Description |
|---|---|---|
| String | String.Empty |
The template in HTML markup.
|
You can use a control’s Designer to specify the HTML-CSS template at design time:
Run Demo: HTML Main Demo — Lab
See the following topic for information on supported HTML tags: HTML Tags.
The example below specifies a sample HTML-CSS template for an HtmlContentControl. This template renders the following UI:
string html =
@"<div class='container background-color1'>
<h3>background-color: LightPink;</h3>
</div>
<div class='container background-color2'>
<h3>background-color: rgb(207, 236, 207);</h3>
</div>
<div class='container background-color3'>
<h3>background-color: rgba(253, 202, 162, 0.7);</h3>
</div>
<div class='container background-color4'>
<h3>background-color: @Question;</h3>
</div>
<div class='container background-color5'>
<h3>background-color: @Blue/0.2;</h3>
</div>";
string css =
@".container {
padding: 10px;
margin-bottom: 10px;
background-color: @Window;
}
.background-color1 {
background-color: LightPink;
}
.background-color2 {
background-color: rgb(207, 236, 207);
}
.background-color3 {
background-color: rgba(253, 202, 162, 0.7);
}
.background-color4 {
background-color: @Question;
}
.background-color5 {
background-color: @Blue/0.2;
}";
htmlContentControl1.HtmlTemplate.Template = html;
htmlContentControl1.HtmlTemplate.Styles = css;
Dim html As String = "<div class='container background-color1'>
<h3>background-color: LightPink;</h3>
</div>
<div class='container background-color2'>
<h3>background-color: rgb(207, 236, 207);</h3>
</div>
<div class='container background-color3'>
<h3>background-color: rgba(253, 202, 162, 0.7);</h3>
</div>
<div class='container background-color4'>
<h3>background-color: @Question;</h3>
</div>
<div class='container background-color5'>
<h3>background-color: @Blue/0.2;</h3>
</div>"
Dim css As String = ".container {
padding: 10px;
margin-bottom: 10px;
background-color: @Window;
}
.background-color1 {
background-color: LightPink;
}
.background-color2 {
background-color: rgb(207, 236, 207);
}
.background-color3 {
background-color: rgba(253, 202, 162, 0.7);
}
.background-color4 {
background-color: @Question;
}
.background-color5 {
background-color: @Blue/0.2;
}"
HtmlContentControl1.HtmlTemplate.Template = html
HtmlContentControl1.HtmlTemplate.Styles = css
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the Template property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
winforms-chat-for-net-framework/CS/DevExpress.AI.WinForms.HtmlChat/ChatControl.cs#L93
string htmlString = Markdig.Markdown.ToHtml(message.Text);
e.Template.Template = e.Template.Template.Replace("${Text}", htmlString);
}
See Also