I'm doing a WPF login interface. In my login panel, I have one login TextBox
and a PasswordBox
. As what shown in the first image below, there is a little human logo in the login textbox and a lock in the password box. I set the image into the textbox background, and then when i try to insert some word into the login box, the words will overide the human logo(image B). Any advice to make it right?
My XAML:
<TextBox Width="380" Height="25" HorizontalAlignment="Center" Foreground="WhiteSmoke" BorderBrush="Transparent" >
<TextBox.Background>
<ImageBrush ImageSource="/icon/user_login.png" AlignmentX="Left" Stretch="None"></ImageBrush>
</TextBox.Background>
</TextBox>
Image A:
Image B:
My suggestion is that you replace each of the
Textbox's
with aDockPanel
. In which they each have anImage
as the left-most item and aTextbox
as the right most. Then set the images to User and Lock respectively. Then set the backgrounds of theTextbox
andImages
to transparent. You can then set whatever styling you want on theDockPanel
.EDIT 1 - Copy paste from working example
Code:
Image:
By not setting the
DockPanel.Dock
property on the second item, I am telling it to stretch across the rest of theDockPanel
. Any other queries, please let me know. If you copy paste the above, it might not look the same, due to me cutting out irrelevant parts.