TileView.CustomDrawTile Event
Allows you to draw tiles manually.
Namespace: DevExpress.XtraGrid.Views.Tile
Assembly: DevExpress.XtraGrid.v24.2.dll
NuGet Packages: DevExpress.Win.Grid, DevExpress.Win.Navigation
#Declaration
[DXCategory("CustomDraw")]
public event EventHandler<TileViewItemCustomDrawEventArgs> CustomDrawTile
#Event Data
The CustomDrawTile event's data class is TileViewItemCustomDrawEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
Appearance |
Gets appearance settings for the painted tile.
Inherited from Tile |
Bounds |
Gets or sets tile bounds.
Inherited from Tile |
Cache |
Gets an object that stores the most used pens, fonts, and brushes.
Inherited from Tile |
Default |
Gets the default bounds of the selection rectangle.
Inherited from Tile |
Default |
Gets the default color of the selection rectangle.
Inherited from Tile |
Default |
Gets the default thickness of the selection rectangle.
Inherited from Tile |
Drawing |
Gets the stage of the drawing process. |
Handled |
Gets or sets whether to skip the default painting.
Inherited from Tile |
Is |
Gets the disabled state of the processed tile.
Inherited from Tile |
Is |
Gets the focused state of the processed tile. |
Is |
Gets the hovered state of the processed tile.
Inherited from Tile |
Is |
Gets the selection state of the processed tile.
Inherited from Tile |
Item | Gets the processed tile. |
Row |
Gets the row handle of the processed tile. |
Should |
Gets whether the tile should display a background.
Inherited from Tile |
Should |
Gets whether the tile should display a border.
Inherited from Tile |
Should |
Gets whether the tile should display a check mark.
Inherited from Tile |
Should |
Gets whether the tile should display content.
Inherited from Tile |
Should |
Gets whether the tile should display a disabled overlay.
Inherited from Tile |
Should |
Gets whether the tile should display a hovered overlay.
Inherited from Tile |
Tile |
Gets the Tile View background. |
The event data class exposes the following methods:
Method | Description |
---|---|
Default |
Draws the processed tile element in its default appearance.
Inherited from Tile |
Draw |
Draws the tile background in its default appearance.
Inherited from Tile |
Draw |
Draws the tile border in its default appearance.
Inherited from Tile |
Draw |
Draws the tile check mark in its default appearance.
Inherited from Tile |
Draw |
Draws tile content in its default appearance.
Inherited from Tile |
Draw |
Draws the overlay for the disabled state in its default appearance.
Inherited from Tile |
Draw |
Draws the overlay for the hovered state in its default appearance.
Inherited from Tile |
Draw |
Paints the specified HTML template inside the processed tile element. The context parameter allows you to assign an object that transfers mouse events to template elements.
Inherited from Tile |
Draw |
Paints the specified HTML template inside the processed tile element.
Inherited from Tile |
#Remarks
The following code snippet demonstrates the default drawing algorithm:
void tileView1_CustomDrawTile(object sender, TileViewItemCustomDrawEventArgs e) {
switch (e.DrawingProcess) {
case TileViewItemCustomDrawProcess.DrawTile:
if (e.ShouldDrawBackground)
e.DrawBackground();
if (e.ShouldDrawContent)
e.DrawContent();
if (e.ShouldDrawHoveredOverlay)
e.DrawHoveredOverlay();
if (e.ShouldDrawDisabledOverlay)
e.DrawDisabledOverlay();
if (e.ShouldDrawBorder)
e.DrawBorder();
if (e.ShouldDrawCheckMark)
e.DrawCheckMark();
break;
case TileViewItemCustomDrawProcess.DrawCheckMark:
e.DefaultDraw();
break;
case TileViewItemCustomDrawProcess.DrawSelection:
e.DefaultDraw();
break;
}
e.Handled = true;
}
ShouldDraw...
conditions allow you to modify specific tile elements.
The following demo uses the CustomDrawTile
event to render HTML and CSS templates inside tiles:
DxHtmlPainterContext context = new DxHtmlPainterContext();
tileView1.CustomDrawTile += (s, e) => {
SampleData obj = tileView1.GetRow(e.RowHandle) as SampleData;
if (obj.Hidden) {
if (e.DrawingProcess == TileViewItemCustomDrawProcess.DrawTile) {
e.DrawBackground();
e.DrawHtml(htmlTemplate, context, (args) => args.InteractivityKey = obj.ID);
e.DrawBorder();
e.Handled = true;
}
}
};
<div class="tile">
<div class="text"><strong>Content of this tile is hidden</strong></div>
<div class="show-action">Show content</div>
</div>
.tile {
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.show-action {
color: deepskyblue;
text-decoration: underline;
cursor: pointer;
}
.show-action:hover {
color: lightskyblue;
}