Reputation: 61
everyone, i want to create the button as attached image Button Image. I want to put text on the image. Does anyone have came across this situation? Please help me with this.
Upvotes: 1
Views: 2539
Reputation: 169420
You could put text on top of an Image by adding a TextBlock to the same Grid as the Image, e.g.:
<Button>
<Button.Template>
<ControlTemplate TargetType="Button">
<Grid>
<Image Source="pic.png" Stretch="None" />
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center">Operation</TextBlock>
</Grid>
</ControlTemplate>
</Button.Template>
</Button>
If you want to rotate the text you could apply a RotateTransform to it:
<Button>
<Button.Template>
<ControlTemplate TargetType="Button">
<Grid>
<Image Source="pic.png" Stretch="None" />
<TextBlock Text="Operation" VerticalAlignment="Center" HorizontalAlignment="Center">
<TextBlock.LayoutTransform>
<RotateTransform Angle="-90" />
</TextBlock.LayoutTransform>
</TextBlock>
</Grid>
</ControlTemplate>
</Button.Template>
</Button>
Upvotes: 4