Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Built in styles override custom styles #142

Open
eylvisaker opened this issue Mar 8, 2024 · 0 comments
Open

Built in styles override custom styles #142

eylvisaker opened this issue Mar 8, 2024 · 0 comments

Comments

@eylvisaker
Copy link

I'm trying to make styles for the Markdown viewer that are applied to the whole application, because I intend to use several of them in different places in my app. The problem I'm having is my app is in dark mode, so I can't see heading text, since the built-in style sets it to black. I can only override the style by putting a Styles property on every MarkdownScrollViewer, which is really annoying.

For example:
My custom style looks like this:

<Style Selector="ctxt|CTextBlock.Heading1"> </Style>

I get the correct styling on the MarkdownScrollViewer if I do this in a UserControl:

          <md:MarkdownScrollViewer xml:space="preserve" Margin="15,0">
            <md:MarkdownScrollViewer.Styles>
              <StyleInclude Source="/Theming/MarkdownStyles.axaml" />
            </md:MarkdownScrollViewer.Styles>
            # Login
            Please enter your username and password to log in.

<md:MarkdownScrollViewer />

But my custom styles are overriden if I do this:

<UserControl.Styles>

</UserControl.Styles>

          <md:MarkdownScrollViewer xml:space="preserve" Margin="15,0">
            # Login
            Please enter your username and password to log in.

<md:MarkdownScrollViewer

In both cases I can see the red background of the heading1. But in the second case, my setting for font weight and foreground color are overriden by the style with what looks like the values coming from here.

I'm not having this problem with any of the built-in Avalonia controls. So I'm not sure if I'm doing something wrong here.

whistyun added a commit that referenced this issue Mar 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant