Skip to content

Customize TextBox colors #383

Answered by SKProCH
SinoAHpx asked this question in Q&A
Jun 21, 2024 · 2 comments · 6 replies
Discussion options

You must be logged in to vote

So, you want override a PrimaryColor for a certain control only? You can actually do it by overriding a resource near the control (Avalonia looks for resources starting from the control and climbing up in visual tree, App resources used when nothing found previously). So, you can do something like this:

<TextBox ...>
  <TextBox.Resources>
    <SolidColorBrush x:Key="MaterialTextBoxBorderBrush" Color="Red" />
    <SolidColorBrush x:Key="MaterialPrimaryMidBrush" Color="Red" />
  </TextBox.Resources>
</TextBox>

Default style for TextBox underline utilizes the following keys: MaterialTextBoxBorderBrush and MaterialPrimaryMidBrush.

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
6 replies
@SinoAHpx
Comment options

@SKProCH
Comment options

@SinoAHpx
Comment options

@SKProCH
Comment options

Answer selected by SinoAHpx
@SinoAHpx
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants