Skip to content

How to customise style CCode

whistyun edited this page Dec 26, 2020 · 1 revision

Abstract

In Markdown.Avalonia, CCode is used for inline code. For now code block is displaied by TextBlock.CodeBlock.

Example

style

<Style Selector="Border.CodeBlock">
    <Style.Setters>
        <Setter Property="BorderBrush"     Value="Blue"/>
        <Setter Property="BorderThickness" Value="0,5,0,5"/>
        <Setter Property="Margin"          Value="5,0,5,0"/>
        <Setter Property="Background"      Value="LightBlue"/>
    </Style.Setters>
</Style>
<Style Selector="TextBlock.CodeBlock">
    <Style.Setters>
        <Setter Property="Foreground"      Value="DarkBlue"/>
        <Setter Property="FontFamily"       Value="Meiryo"/>
    </Style.Setters>
</Style>

<Style Selector="ctxt|CCode">
    <Style.Setters>
        <Setter Property="BorderBrush" Value="Green"/>
        <Setter Property="BorderThickness" Value="2"/>
        <Setter Property="Padding" Value="2"/>
        <Setter Property="MonospaceFontFamily" Value="Meiryo" />
        <Setter Property="Foreground" Value="DarkGreen" />
        <Setter Property="Background" Value="LightGreen" />
    </Style.Setters>
</Style>

markdown

inline code: `this is inline.`

```c
#include <stdio.h>
int main()
{
   // printf() displays the string inside quotation
   printf("Hello, World!");
   return 0;
}
```

view

view

Support Styles(CCode)

Basic

  • Foreground
  • Background
  • FontFamily: It's not work correctly.
  • FontWeight
  • FontSize
  • FontStyle
  • BorderThickness
  • BorderBrushProperty
  • CornerRadiusProperty
  • BoxShadowProperty
  • PaddingProperty
  • MarginProperty

Others

  • IsUnderline

    If true is set, draw line under the text.

  • IsStrikethrough

    If true is set, draw strikethrough in the text.

  • MonospaceFontFamily

    In CCode, this is treat as FontFamily.