Property Elements

Rich composition of controls is one of the highlights of XAML. This can be easily demonstrated with a Button, because you can put arbitrary content inside it; you’re not limited to just text! To demonstrate this, the following code embeds a simple square to make a Stop button like what might be found in a media player:

Windows.UI.Xaml.Controls.Button b = new Windows.UI.Xaml.Controls.Button(); b.Width = 96; b.Height = 38; Windows.UI.Xaml.Shapes.Rectangle r = new Windows.UI.Xaml.Shapes.Rectangle(); r.Width = 10; r.Height = 10; r.Fill = new Windows.UI.Xaml.Media.SolidColorBrush(Windows.UI.Colors.White); b.Content = r; // Make the square the content of the Button

Button’s Content property is of type ...

Get Universal Windows® Apps with XAML and C# Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.