#67 – XAML Attributes Map to Property Values

In the same way that XAML elements map to instances of .NET types, XAML attributes map to properties of those types.

In the example below, we create a new instance of a Button and then specify values for the following properties: Content, Height, Width, Name and Background.

<Button Content="Press Me" Height="23" Name="button2" Width="75" Background="#FFE3E316" />

Note that we set each property by specifying a string, despite the Button object’s properties having different types:

  • Content – object
  • Height - double
  • Width - double
  • Name - string
  • Background - System.Windows.Media.Brush

When the XAML file is processed, the string values will be converted to the appropriate types.

About these ads

About Sean
Software developer in the Twin Cities area, passionate about .NET technologies. Equally passionate about my own personal projects related to family history and preservation of family stories and photos.

2 Responses to #67 – XAML Attributes Map to Property Values

  1. Pingback: #70 – Specifying Event Handlers in XAML « 2,000 Things You Should Know About WPF

  2. Pingback: #78 – Setting the Value of a Content Property By Setting Child Element « 2,000 Things You Should Know About WPF

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

Follow

Get every new post delivered to your Inbox.

Join 311 other followers

%d bloggers like this: