Reputation:
I'm trying to make a password box eye in wpf, I need the eye icon in the middle but it goes to left top corner, how to fix?
Here my xaml:
<Button x:Name="button" HorizontalAlignment="Left" Height="26" Margin="215,38,0,0" VerticalAlignment="Top" Width="30">
<Button.Background >
<ImageBrush ImageSource="../pics/eye3.png" Stretch="None" AlignmentX="Center" AlignmentY="Center">
<ImageBrush.Transform>
<ScaleTransform ScaleX=".5" ScaleY=".5"/>
</ImageBrush.Transform>
</ImageBrush>
</Button.Background>
</Button>
Here is the result:
Link for the eye image download: link,
Smartio bean
Upvotes: 0
Views: 380
Reputation: 128013
Instead of an ImageBrush in the Button's Background, you could simply put an Image element in the Button's Content:
<Button ...>
<Image Source="../pics/eye3.png" Stretch="None">
<Image.LayoutTransform>
<ScaleTransform ScaleX=".5" ScaleY=".5"/>
</Image.LayoutTransform>
</Image>
</Button>
Upvotes: 1