How to add a Label inside a TextBlock by code behind

2

How do I add these Labels within TextBlock , code behind ?

<TextBlock>
    <Label x:Name="NumeroPergunta" FontWeight="Bold" />
    <Label x:Name="Pergunta" />
</TextBlock>

What I have so far:

var tbPergunta = new TextBlock {Text = pergunta.Pergunta};
    
asked by anonymous 24.12.2014 / 12:17

1 answer

1

I was able to use the Inlines property of Textblock :

First I created the Labels dynamically:

var lblNumeroPergunta = new Label
{
    Content = contNumeroPerguntas.ToString(),
    FontWeight = FontWeights.Bold
};
var lblPergunta = new Label { Content = pergunta.Pergunta };

Then I created TextBlock

var tbPergunta = new TextBlock();

And finally, by using the

24.12.2014 / 12:30