Mastering Visual Studio 2017
上QQ阅读APP看书,第一时间看更新

Object element syntax

The XAML object element declares an instance of a type. Each object element starts with an opening angular bracket (<) followed by the name of it. Optionally, it can have a prefix to define its namespace outside of the default scope. The object element can be closed by a closing angular bracket (>) or with a self-closing angular bracket (/>). When the object element has a child element, we use the first one followed by the end tag (<Button>Click Here</Button>), and for the other case, a self-closing element (<Button Content="Click Here" />) is used.

When you specify the object element in an XAML page, the instruction to create an instant of the element is being generated and when you load the XAML, it creates the instance by calling the default constructor of the same.