A Silverlight Page is a Canvas

When trying to figure out how to dynamically set a TextBlock’s Text value, I discovered that a Silverlight Page class is actually a subclass of Canvas.

The declaration tells all:

public partial class Page : Canvas

… and with a little digging, helped me find a way to dynamically set the text:

public void Page_Loaded(object o, EventArgs e)
{
    // Required to initialize variables
    InitializeComponent();
    Canvas cc = o as Canvas;
    TextBlock tb = cc.Children[0] as TextBlock;
    tb.Text = "Fourscore and seven years ago...";
}
Advertisements

0 Responses to “A Silverlight Page is a Canvas”



  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s





%d bloggers like this: