How remove focus borders of TextBox?

杨岑 166 Reputation points
2024-05-09T14:21:55.8366667+00:00

I personally don't like the thick borders when a TextBox gets focus. Is there any way to remove it?

Universal Windows Platform (UWP)
0 comments No comments
{count} votes

Accepted answer
  1. Junjie Zhu - MSFT 15,911 Reputation points Microsoft Vendor
    2024-05-10T02:42:43.56+00:00

    Hi @杨岑

    The default template of Textbox can be found in generic.xaml in: C:\Program Files (x86)\Windows Kits\10\DesignTime\CommonConfiguration\Neutral\UAP\{version}\Generic.

    You can also right-click the Textbox control in Xaml Desginer Window, select Edit Template->Edit a Copy, then you can get a new Style resource code of the Textbox control in xaml.

    Find the resource TextControlBorderBrushFocused and TextControlBorderBrushPointerOver,modify their value with new SolidColorBrush.

        <Page.Resources>
            <StaticResource x:Key="TextControlBorderBrushFocused" 
                            ResourceKey="SystemControlForegroundBaseMediumLowBrush" />
            <StaticResource x:Key="TextControlBorderBrushPointerOver" 
                            ResourceKey="SystemControlForegroundBaseMediumLowBrush" />
        </Page.Resources>
        <Grid>
            <StackPanel>
                <TextBox Height="50" Width="200"/>
                <TextBox Height="50" Width="200"/>
            </StackPanel>
        </Grid>
    

    Thank you.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful