Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

TextBlock with Text parameter

$
0
0

Hello

I'm encountering the following problem: I got a TextBlock that I programmatically create and I want to use the "template" but with different text content as in the following example:

TextBlock generalTextBlock = new TextBlock
{
    FontSize = 20,
    TextWrapping = TextWrapping.Wrap,
    Foreground = new SolidColorBrush(Colors.Yellow)
};

And I would like to use it as this

generalTextBlock("Text sample" + Environment.NewLine + "Another line" + randomString);

I know the answer is pretty lame and that this is a question for beginners but I've never had to use it before and the examples provided didn't help me.

Please ignore the attributes cause they are taken out of a Windows Phone app, but the question seemed more relevant over here.

Thanks anticipated!


Viewing all articles
Browse latest Browse all 12583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>