Cannot change textbox color (while writing) #19616
-
This is my textbox xaml- <Style x:Key="CustomTextBoxStyle" TargetType="TextBox" BasedOn="{StaticResource OutlinedTextBoxStyle}"> </Style>I want the font color of this textbox to be black. But the placeholder color is grey and when i start typing it is still grey. Only when i'm out of focus it changes to black. I've tried setting PlaceholderForeground to black too. but it's still not working. does anyone know how can i fix this? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hello! This would typically be done through the use of Lightweight Styling. The There is a dedicated SolidColorBrush resource for each of the visual states relating to the placeholder foreground. These resources are overridable and can be customized. You can find all of the overridable resources and their default values for the TextBox here: https://platform.uno/docs/articles/external/uno.themes/doc/styles/TextBox.html In your case, you should be able to override these resources with your own colors: You can refer to examples done in the Uno Gallery app/ app on the Lightweight Styling page: https://github.com/unoplatform/Uno.Gallery/blob/5a8248e089f0496d124648ac37691059b9853016/Uno.Gallery/Views/SamplePages/LightweightStylingSamplePage.xaml#L112-L114 Note the differences in foreground for the placeholder changes based on the Focused visual state: |
Beta Was this translation helpful? Give feedback.
Hello!
This would typically be done through the use of Lightweight Styling. The
OutlinedTextBoxStyle
inside of Uno Material changes the Foreground of the PlaceholderText based on the current Visual State. For reference, this is where that happens: https://github.com/unoplatform/Uno.Themes/blob/74567f3f629fef5ed52018ddc4579ec209d894eb/src/library/Uno.Material/Styles/Controls/v2/TextBox.xaml#L666-L696There is a dedicated SolidColorBrush resource for each of the visual states relating to the placeholder foreground. These resources are overridable and can be customized.
You can find all of the overridable resources and their default values for the TextBox here: https://platform.uno/docs/arti…