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
    Canvas cc = o as Canvas;
    TextBlock tb = cc.Children[0] as TextBlock;
    tb.Text = "Fourscore and seven years ago...";

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 )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

TwitterCounter for @anthonyrstevens
Add to Technorati Favorites

RSS Feed

View Anthony Stevens's profile on LinkedIn

%d bloggers like this: