Joe Lu
Joe Lu

Reputation: 2370

partial styling for textblock text programmatically

newbie in wp development, used to do this in visual studio web express, can I do the similar attempt in wp?

str = "abc ddd efg" mylabel.text = str

basically i want to bold partial text in a static string, and display it on label/textblock, any idea? tks

Upvotes: 1

Views: 260

Answers (1)

venerik
venerik

Reputation: 5904

The TextBlock has an Inlines property. You can add formatted text to that collection:

mylabel.Inlines.Clear();            
mylabel.Inlines.Add("abc");
mylabel.Inlines.Add(new Run() { Text="ddd", FontWeight=FontWeights.Bold });
mylabel.Inlines.Add("efg");

Upvotes: 2

Related Questions