Home > Enterprise >  Changing outlined TextBox default border brush
Changing outlined TextBox default border brush

Time:12-06

Currently, when TextBox is not selected, the BorderBrush is black. However, when TextBox is selected, the BorderBrush becomes green. How would I go about setting the BorderBrush to be say blue by default when not selected instead of black?

<TextBox 
    Margin="0,15,0,0"
    Foreground="#FFFFFF"
    FontSize="20"
    materialDesign:TextFieldAssist.UnderlineBrush="Green"
    materialDesign:HintAssist.Background="Transparent"
    Style="{StaticResource MaterialDesignOutlinedTextBox}"
    materialDesign:HintAssist.Hint="Username"
    materialDesign:HintAssist.Foreground="Green"
    />

CodePudding user response:

You can just set the BorderBrush

<TextBox BorderBrush="Blue" />

CodePudding user response:

You have to override the following brushes:

  • MaterialDesignTextAreaBorder - For the border in enabled state.
  • MaterialDesignTextAreaInactiveBorder - For the border in disabled state (IsEnabled="False").
<TextBox 
   Margin="0,15,0,0"
   Foreground="#FFFFFF"
   FontSize="20"
   materialDesign:TextFieldAssist.UnderlineBrush="Green"
   materialDesign:HintAssist.Background="Transparent"
   Style="{StaticResource MaterialDesignOutlinedTextBox}"
   materialDesign:HintAssist.Hint="Username"
   materialDesign:HintAssist.Foreground="Green">
   <TextBox.Resources>
      <SolidColorBrush x:Key="MaterialDesignTextAreaBorder" Color="Blue"/>
      <SolidColorBrush x:Key="MaterialDesignTextAreaInactiveBorder" Color="LightBlue"/>
   </TextBox.Resources>
</TextBox>
  • Related