Skip to main content
All docs
V23.2

HtmlTemplate.Styles Property

Gets or sets the template’s CSS code that specifies the appearance settings, size, padding, and layout options of UI elements.

Namespace: DevExpress.Utils.Html

Assembly: DevExpress.Utils.v23.2.dll

NuGet Packages: DevExpress.Utils, DevExpress.Wpf.Core

Declaration

[DefaultValue("")]
public string Styles { get; set; }

Property Value

Type Default Description
String String.Empty

The template’s CSS code.

Remarks

You can use a control’s Designer to specify the HTML-CSS template at design time:

ListBoxControl-Html-Template

Run Demo: HTML Main Demo — Lab

See the following topic for information on supported CSS properties: CSS Styles.

Example

The example below specifies a sample HTML-CSS template for an HtmlContentControl. This template renders the following UI:

HtmlContentControl - Sample - Background

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;
See Also