
228Microsoft Visual Studio 2010: A Beginner’s Guide
In Figure
Below the Designer, the Button control appears in the XAML for this window. If you are uncomfortable looking at XAML, you can review Appendix B as a refresher. The attributes of the Button control in the XAML match the properties in the Properties window.
TIP
It’s important to learn how to quickly build UIs using the Visual Designer because it enhances productivity. However, it’s also important to be able to read the XAML associated with a window because as you move beyond the beginner content of this book, you’ll find scenarios where the Designer alone might not allow you to control every nuance of your visual presentation. A good way to move forward is to experiment on your own by adding each of the controls from the Toolbox to the Designer and then examine the generated XAML.
Setting Properties
The Properties window shows all of the ways that you can configure a control. For button controls, you’ll want to change the Content property to make the text on the button make sense. In this example, we’ll imagine that the purpose of the button is to allow a user to create a new order for a customer. Therefore, set the Content property to New Order.
Handling Events
In addition to properties, you can handle control events via the Events tab at the top of the Properties window. Figure
Controls have literally dozens of events that allow you to manage their behavior in the application. Some events, like Click, are commonly used, while other events, such as Drag Over, only support unique scenarios like drag and drop that you might not ever care about. To handle an event, you can
Since the Click event is so common, I’ll show how it works. You can implement a handler for the Click event by
.xaml.cs is called a