Search code examples
xamarinuwpbackgroundcontroltemplatepasswordbox

Background at passowordBox in the uwp


I am using the uwp component password box (XAMARIN) and set a certain image as the background, but when I click on the box, the background changes. I would like to keep the background static.

   <PasswordBox x:Name="PasswordUser">
            <PasswordBox.Background  >
                <ImageBrush ImageSource="/Assets/Login/campo-senha.png"/>
            </PasswordBox.Background>
</PasswordBox>

PasswordBox.Background before clicked

enter image description here

PasswordBox.Background after clicked

enter image description here

So I would like the background to remain as I set it, always even when I click click on the box.


Solution

  • Please check PasswordBox style xaml, the password background has point over and focused status. so you need re-write the following resource with the ImageBrush that contains the same image source. You could place the follow resource in the page resource or application resource base on your design.

    <ImageBrush x:Key="TextControlBackgroundPointerOver" ImageSource="/Assets/bgimg.png" />
    <ImageBrush x:Key="TextControlBackgroundFocused" ImageSource="/Assets/bgimg.png" />