Search code examples
c#wpfwindows-phone-8windows-phone-8.1image-formats

Dynamically add text in an image on Xaml/Windows Phone


I have a XAML ListBox where I am implementing an Image beside that a block of text is there. I want to display a count text in that image. For example for the first block in the image I want to display 1, for the 2nd block I want to display 2. This goes on. Below is the snippet. Can anybody please help me how can I write the count numbers in the image?

 <StackPanel Grid.Column="0">
 <Image Source="/Assets/Images/pin.png"></Image>
  </StackPanel>
    <TextBlock Name="locationID" Visibility="Collapsed" ></TextBlock>
  </StackPanel>
 </StackPanel>

Solution

  • here you go

    <Grid Grid.Column="0">
        <Grid.Background>
            <ImageBrush ImageSource="/Assets/Images/pin.png"/>
        </Grid.Background>
        <TextBlock Text="text on image" Name="locationID" />
    </Grid>
    

    whole idea is to place the image as background of grid and place the text as content of the grid.