CHAPTER 4 EXERCISE SOLUTIONS

Exercise 1 Solution

The answer here is d, BasedOn styling. BasedOn styling allows you to create a base style containing values that will be common to a particular set of controls. That set of controls must be the same type, however. In this case, you can build a base style to hold the value for Margin, Padding, and Background and then create the additional styles for the rest of the Button objects that will contain the properties that differ.

Exercise 2 Solution

Choices a and b are the only valid animation objects in the list. You can use the ColorAnimation object to animate from one color to another over a specified period of time. You can use the DoubleAnimation object to change any property with a double type, such as Opacity. This object will perform the animation smoothly over a set period of time.

Exercise 3 Solution

True. Controls can be in multiple states as long as the states have been assigned to different VisualStateGroup declarations.

Exercise 4 Solution

The answer is d, override OnApplyTemplate. When creating custom controls that contain several Silverlight controls in the default style template, you should override the OnApplyTemplate method in order to gain access to any controls in the template.

Exercise 5 Solution

True. When creating custom controls, it is best to add corresponding DependencyProperty objects along with any custom properties. Doing so ensures that those properties are supported properly by tools such as Visual Studio ...

Get Beginning Windows® Phone 7 Application Development: Building Windows® Phone Applications Using Silverlight® and XNA® 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.