Microsoft 9GD00001 Computer Accessories User Manual


 
412 Microsoft Visual Studio 2010: A Beginner’s Guide
Property Elements
You’ve seen how attributes translate to properties. In addition to attributes, XAML has
property elements, which are child elements where one or more other elements become
assigned to a property. An example of a property element would be the Content property
of a Button. A Button is a class in both WPF and Silverlight that a user can click to
produce some action in your program. The Content property of the Button determines
what the user sees. To describe the difference between a property attribute and a property
element, I’ll show you an example of both with the Content property of the Button class.
Listing B-2 shows a Button with its Content set as an attribute.
Listing B-2 A Button with Content set as an attribute
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Button Content="Click Me" />
</Window>
Figure B-1 Executing XAML