shubhguru28
shubhguru28

Reputation: 55

How to change Border Color of TextBox on Focus in UWP

I am developing an Universal Windows Platform App using XAML & C#. I want to change Border Color of TextBox on Focus in UWP.

Thanks in advance for Help.

Upvotes: 3

Views: 3988

Answers (2)

Dark Templar
Dark Templar

Reputation: 1155

Well it is actually very simple to achieve, just follow these steps:


Step 1. add a textbox to your page.


step 2. right click on your textbox and pick : "EditTemplate" \ "Edit a Copy..."

this will take you to the template designer stage.


step 3. check this image: https://postimg.org/image/ocdn34is1/

Upvotes: 3

Romasz
Romasz

Reputation: 29792

You need to edit the Style of your TextBox, the default one you can generate via designer or take from MSDN. There in visual states you will find Focused - change whatever you want in it:

<VisualState x:Name="Focused">
   <Storyboard>
      ... some code
        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="BorderElement"
                                       Storyboard.TargetProperty="BorderBrush">
           <DiscreteObjectKeyFrame KeyTime="0" Value="Green"/>
        </ObjectAnimationUsingKeyFrames>
      ... some code
   </Storyboard>
</VisualState>

Upvotes: 1

Related Questions