Random programming things I'd want to remember

Wednesday, May 2, 2012

How to dynamically add a Border around TextBlock in Silverlight





TextBlock b = new TextBlock();
b.VerticalAlignment = System.Windows.VerticalAlignment.Top;
b.FontSize = 28;
b.TextWrapping = TextWrapping.Wrap;
b.Width = 430;
b.Text = "Hello World!";

Border a = new Border();
a.BorderThickness = new Thickness(2);
a.BorderBrush = new SolidColorBrush(Colors.Blue);
a.Child = b;