UWP TextBox Background when Focused

Do this in your App.xaml file:

<Application>
    <Application.Resources>
        <SolidColorBrush x:Key="TextControlBackgroundFocused" Color="Black" Opacity="0.2"/>
        <SolidColorBrush x:Key="TextControlForegroundFocused" Color="White"/>
        <SolidColorBrush x:Key="TextControlBorderBrushFocused" Color="White" Opacity="0.2"/>
    </Application.Resources>
</Application>

This will overwrite the default colors with your own custom colors for every TextBox in your project. If you want to apply the appearance to only some of your TextBoxes, define it locally for each TextBox:

<TextBox>
    <TextBox.Resources>    
        Put brushes here
    </TextBox.Resources>
</TextBox>

It would be easier to create a style and then apply it. At design time you can use the Document Outline pane in Visual Studio and right-click the TextBox. Then choose the Edit Template -> Edit Copy. Then modify that style in the same way you have done in your question.

Tags:

C#

Xaml

Uwp