Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do we set background image of TextBlock in Windows Phone?

I am facing problem in setting the background of textblock in Windows Phone.

<TextBlock Text="Forget Password" Height="19" Width="156">
like image 256
Altaf Avatar asked Jan 24 '11 08:01

Altaf


2 Answers

The TextBlock element cannot display a background image. You can display an image behind your TextBlock as follows:

<Grid>
    <Image Source="..."/>
    <TextBlock Text="Forget Password" Height="19" Width="156">
</Grid>

You might have to apply a suitable Margin or padding to your image for this to work.

If you want to add images to a number of TextBlocks, you might want to consider re-templating yor TextBlock via a Style.

like image 80
ColinE Avatar answered Nov 03 '22 00:11

ColinE


You can use a border control to contain the TextBlock:-

<Border Background="{StaticResource KeyToDesiredBackgroundBrush}">
   <TextBlock Text="Forget Password" Height="19" Width="156" />
</Border>
like image 45
AnthonyWJones Avatar answered Nov 03 '22 01:11

AnthonyWJones