Reputation: 5170
I am facing problem in setting the background of textblock in Windows Phone.
<TextBlock Text="Forget Password" Height="19" Width="156">
Upvotes: 5
Views: 7796
Reputation: 2730
You can try this:
<Grid>
<Grid.Background>
<ImageBrush ImageSource="MyImage.jpg" />
</Grid.Background>
<TextBlock Text="Forget Password" />
</Grid>
Upvotes: 3
Reputation: 189457
You can use a border control to contain the TextBlock
:-
<Border Background="{StaticResource KeyToDesiredBackgroundBrush}">
<TextBlock Text="Forget Password" Height="19" Width="156" />
</Border>
Upvotes: 5
Reputation: 70142
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.
Upvotes: 6