Search code examples
xamlmicrosoft-metro

How do I add text inside a shape in XAML


I am working on a Metro App using C++ and XAML. I want to create a polygon shape and add text inside it.

At first I thought of defining my own Controltemplate and apply it to Textblock but unfortunately it does not understand TargetType = "TextBlock".

Secondly, I thought of inheriting the Polygon class and see if I can do anything there but that class is sealed.

Any ideas on how to achieve this?


Solution

  • In WPF XAML you could do something simple like this:

    <Grid Width="60" Height="100">
        <Ellipse Fill="Yellow"/>
        <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" Text="Hello"/>
    </Grid>
    

    To get text in the centre of a yellow ellipse.

    I'm guessing something that simple will work on WinRT.