WinForms HTML & CSS Templates — New Controls and Features

WinForms Team Blog
29 April 2022

A few days ago, we announced support for HTML & CSS templates in our Alert Control. As last week’s post outlined, HTML & CSS templates allow you to create custom/modern notifications with ease. In this post, I'll share a few more template-related updates you can expect from our v22.1 release.

ListBox Control

In previous releases, we introduced standard templates for the WinForms ListBox Control — a designer similar to one available in the Tile View allows you to easily arrange elements across a ListBox item surface. HTML & CSS templates available in v22.1 will take this customization flexibility to a whole new level.

This image was taken from our updated HTML Demo Center module. We're using the following HTML markup to create this sample UI.

<div class="contact">
    <div class="contact-avatar">
        <img class="photo" src="${Photo}" />
        <div class="status" id="status"></div>
    </div>
	<div>
        <div class="contact-body">
            <div class="contact-info">
                <div class="name-info">
                    <div class="name">${FirstName} {LastName}</div>
                    <img class='info' src='Contact' id="info" />
                </div>
                <div class="phone">${HomePhone}</div>
            </div>
        </div>
        <div class='selection'></div>
	</div>
</div>

ComboBox Edit

The ComboBox Edit is yet another logical candidate for web-inspired templates. Similar to ListBox Edit templates, you can utilize ${FieldName} syntax to add data placeholders. At runtime, these placeholders are replaced with actual values from a Data Source. As you can see below, this makes our HTML & CSS templates a perfect tool for building data-aware control layouts.

The template for this sample ComboBox Edit UI is as follows:

<div class="contact">
    <div class="contact-avatar">
        <img class="photo" src="${Photo}" />
    </div>
	<div>
        <div class="contact-body">
            <div>
                <div class="name">${FirstName} {LastName}</div>
                <div class="label">${Department}</div>
            </div>
        </div>
        <div class='selection'></div>
	</div>
</div>

Item AutoHeight for TileView Templates

HTML & CSS template support for our TileView was introduced in the v21.2 release cycle. With our upcoming release, you’ll be able to adjust tiles based on content size.

To enable this feature, simply set the OptionsHtmlTemplate.ItemAutoHeight property to true.

At the markup level, you do not need to do anything unusual. The image above is created using the following HTML code.

<div class="container">
	<div class="card">
		<div class="stripe" id="stripe"></div>
		<div class="content">
			<div class="top-block">
				<div class="caption"><b>${Name}</b></div>
			</div>
			<div class="description">${Description}</div>
			<div class="bottom-block">
				<div class="bottom-block-near">
					<div><span style="color:@DisabledText">Due Date: </span>${DueDate}</div>
					<div><span style="color:@DisabledText">Employee: </span>${Employee}</div>
				</div>
				<div class="status">${Status}%</div>
			</div>
		</div>
	</div>
</div>

Your Opinion Matters

Tell us what you think about these newest additions. Have you already designed layouts with our web-inspired templates?

Free DevExpress Products – Get Your Copy Today

The following free DevExpress product offers remain available. Should you have any questions about the free offers below, please submit a ticket via the DevExpress Support Center at your convenience. We’ll be happy to follow-up.
Benjamin Hofmann
Benjamin Hofmann

This is all exciting :)

I am curious to see your solution for a simpler localization.

Thanks for the great work.

29 April 2022
dbSoft
dbSoft

Hello Devexpress, we defenately  encourage you to keep going with css-html styles.

Item AutoHeight for TileView Templates is something that we was waiting for... So keep growing this exellent job!!

29 April 2022
Ben Holtzman
Ben Holtzman
I like the new ability. It seems intuitive and allows for skill reuse. Thanks for the update!
30 April 2022
Christopher Jay
Christopher Jay
Great work.  Love it.
30 April 2022
Lior
Jim

Very nice.
Will the HTML and CSS templates also support RTL languages ?

2 May 2022
Dmitry (DevExpress)
Dmitry Korovin (DevExpress)
@Jim our main priorities right now are to support Templates for more controls that could benefit the most from it and to expand the list of supported tags. RTL mode support is not in our immediate plans, but I can definitely see it included in a roadmap for later versions.
2 May 2022
Uwe Keim
Uwe Keim
I assume that this both works with normal DPI and high DPI mode/displays correctly. Right?
3 May 2022
Dmitry (DevExpress)
Dmitry Korovin (DevExpress)

@Uwe Sure, images in all my posts for the last couple of years are shot at 4K resolution, 200% Windows scale; so whenever you see a post, it means the related feature was already tested on a high DPI display :)

3 May 2022
Customer59081
Tridip

Controls looks very smart and attractive. how a new user will be able to know that how to develop such UI. it will be great help if customer get sample code which they can download and run in their pc,


Thanks a lot.

19 May 2022
CRM-84c1ddc4-d6b1-4a7e-b2d8-53440b611cc4
jiri trunkat
awesome
7 June 2022
Customer76333
OlafD
Are nested properties supported now? 
Example: ${Customer.Address.Street}

Still waiting :-)​
 
8 June 2022
CRM-cd64998e-c2c1-4ce0-977f-01789d8d1d11
Mike McDonald
Are these WinForms HTML & CSS Templates also available for other controls ie GridControl? 
21 June 2022
CRM-cd64998e-c2c1-4ce0-977f-01789d8d1d11
Mike McDonald
Are these WinForms HTML & CSS Templates also available for other controls ie GridControl? 
21 June 2022
Dmitry (DevExpress)
Dmitry Korovin (DevExpress)

@OlafD - nested properties are working inside Data Grid, Alert Control, or any other DevExpress WinForms control that supported data binding long before these templates. However, it's not yet available for the HtmlContentControl - this is a new component and does not have the required infrastructure yet. We hope to fix that in our nearest updates.


@Mike McDonald sure, the list of currently supported controls includes Data Grid, Gantt Control, Accordion Control, and more. See this help article for the complete list: HTML and CSS-based Desktop UI.

22 June 2022

Please login or register to post comments.