MaterialDesign Underline Color Of TextBox in Wpf

Viewed 876

I have more than one TextBox. I want to change the underlines depending on special circumstances. I'm using the MaterialDesign style. I want to change the underline of the TextBox. It's a feasible situation in XAML, but how can I do it in code-behind? TextboxName.Underline cannot be found.

My xaml code

<TextBox x:Name="Pulse2" Style="{StaticResource MaterialDesignFloatingHintTextBox}" VerticalAlignment="Top" HorizontalAlignment="Left"
         Foreground="{Binding Foreground, ElementName=CardID}" Height="43" Width="132" IsReadOnly="True"
         materialDesign:TextFieldAssist.UnderlineBrush="{Binding Background, ElementName=HaltButton}"
         materialDesign:HintAssist.Foreground="#244886"
         AcceptsReturn="True" TextWrapping="Wrap" VerticalScrollBarVisibility="Auto"
         materialDesign:HintAssist.Hint="Pulse2" Margin="281,136,0,0"/>

Not Found

Pulse.Underline !!!
2 Answers

You can use the setter for the UnderlineBrush property on TextFieldAssist to set any Brush e.g.:

TextFieldAssist.SetUnderlineBrush(Pulse2, Brushes.Black);

thatguy,

TextFieldAssist.DecorationVisibility(txtLastName, (MainWindow.btnEditing == Enums.Editing.View) ? "Hidden" : "Visible");

error CS0103 "The name 'TextFieldAssist' does not exist in the current context!!

Related