Skip to content

How to customise style Table

whistyun edited this page Dec 5, 2020 · 1 revision

Abstract

In Markdown.Avalonia, Table is rendered used by Grid and Border control. both controls have 'Table' class. Each table cell is And list mark is CTextBLock which has 'ListMaker'

liststrc

Example

style

<!--
    xmlns="https://github.com/avaloniaui"
-->
<Style Selector="Border.Table">
    <Setter Property="Padding" Value="2"/>
    <Setter Property="BorderBrush" Value="Red"/>
    <Setter Property="BorderThickness" Value="2"/>
</Style>

<Style Selector="Grid.Table">
    <Setter Property="Background" Value="Gray"/>
</Style>

<Style Selector="Border.TableHeader">
    <Setter Property="Margin" Value="2"/>
    <Setter Property="BorderBrush" Value="Blue"/>
    <Setter Property="BorderThickness" Value="2"/>
    <Setter Property="Background" Value="LightBlue"/>
</Style>

<Style Selector="Border.OddTableRow">
    <Setter Property="Margin" Value="3"/>
    <Setter Property="BorderBrush" Value="Green"/>
    <Setter Property="BorderThickness" Value="2"/>
    <Setter Property="Background" Value="LightGreen"/>
</Style>

<Style Selector="Border.EvenTableRow">
    <Setter Property="Margin" Value="5"/>
    <Setter Property="BorderBrush" Value="Magenta"/>
    <Setter Property="BorderThickness" Value="2"/>
    <Setter Property="Background" Value="LightPink"/>
</Style>

<Style Selector="Border.TableHeader ctxt|CTextBlock">
    <Setter Property="FontWeight" Value="Thin"/>
    <Setter Property="FontStyle" Value="Italic"/>
</Style>

markdown

|  column1   |  column2   |
|------------|------------|
| odd  cell1 | odd  cell2 |
| even cell1 | even cell2 |
| odd  cell1 | odd  cell2 |
| even cell1 | even cell2 |

view

view