neolithos / NeoMarkdigXaml

Markdig Xaml/Wpf Renderer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Custom styling

LaurentMinot opened this issue · comments

Hello,
Could you detail a bit more on how to have a custom styling? It seems a bit complicatd to achieve.

What I tried (without success):

image

image

image

image

Ok it was easier that what I thought.
No need to use custom classes, just overriding styles works.
I think a few notes in readme would be helpful.

Until now I didn't know to that people use this library.

I will see what I can do!

@LaurentMinot I'd be curious to know what you did. I just statically referenced the keys with no luck:

<UserControl ...
             xmlns:md="clr-namespace:Neo.Markdig.Xaml;assembly=Neo.Markdig.Xaml"
             ... >
<Style TargetType="{x:Type Paragraph}" x:Key="{x:Static md:MarkdownXaml.Heading1StyleKey}">
    <Setter Property="FontSize" Value="42" />
    <Setter Property="Foreground" Value="Red" />
    <Setter Property="FontWeight" Value="Bold" />
</Style>

<Style TargetType="{x:Type Paragraph}" x:Key="{x:Static md:MarkdownXaml.Heading2StyleKey}">
    <Setter Property="FontSize" Value="20" />
    <Setter Property="Foreground" Value="Red" />
    <Setter Property="FontWeight" Value="Bold" />
</Style>

<Style TargetType="{x:Type Paragraph}" x:Key="{x:Static md:MarkdownXaml.Heading3StyleKey}">
    <Setter Property="FontSize" Value="18" />
    <Setter Property="Foreground" Value="Red" />
    <Setter Property="FontWeight" Value="Bold" />
</Style>

@LaurentMinot I would also be interested to know what you did.

This will not work, because my styles in MarkdownXaml are bind to an assembly. I change them to internal.

You need to override GetDefaultStyle to return you own resource keys.

If someone has a good idea to make it better. I am open for it.