Background textblock on windows phone

windows-phone-7, xaml

Solution

TextBlock doesn't have a background property on its own. You have to put up a background grid or canvas or border or rectangle to full fill it.

<Grid Width="300" Height="100" Background="Blue">
    <TextBlock Name="MyTextBlock" Text="Hello World!" Foreground="Black" />
</Grid>

Instead of grid you can make a rectangle or border.

Problem

I want to change background color on TextBlock on Windows phone. Now I've only got a textblock colored without a space near frame. This effect I've got by this code: ``` <StackPanel Orientation="Horizontal" Background="{Binding Color}"> <TextBlock Text="{Binding Name}" Margin="12,0,0,0"></TextBlock> </StackPanel> ```

Original source