|
|
Developing for Windows Phone and Xbox Live : Using SkinnedEffect |
Animation for a particular model is normally stored within the model itself and is included when you are importing and processing the model. However, by default, you won’t be able to get this data at runtime, so you need to build a content processor to store this data. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Programming Windows Phone 7 : Items Controls - A Card File Metaphor |
OverlapPanel defines an Orientation property and arranges its children either horizontally or vertically. If OverlapPanel is arranging its children horizontally, each child is positioned slightly to the right of the child before it, leaving the left-most sliver of the previous child visible. |
|
|
|
|
Items Controls : Fun with DataTemplates |
To play along, you can create a new project, set a reference to the ElPasoHighSchool library, and in the XAML file add an XML namespace declaration for that library and instantiate the StudentBodyPresenter class in the Resources collection |
|
Items Controls : Databases and Business Objects |
The Students property is of type ObservableCollection, which of course implements IEnumerable, which is all that ListBox really requires for its ItemsSource. But ListBox also determines if the object bound to ItemsSource can do a little more, for example, if it implements INotifyCollectionChanged, which ObservableCollection does. |
|
|
Items Controls : ListBox Selection |
A SelectionChanged event is fired when the selection changes. This event implies that SelectedItem is a good choice for a binding source. SelectedItem is backed by a dependency property, so it can also serve as a binding target. |
|
Items Controls : Customizing Item Displays |
The ItemsControlsFromXaml project uses this approach to fill an ItemsControl and two ListBox controls. The Items property defined by ItemsControl is the content property of the control, so in XAML all you need to do is put a bunch of objects between the begin and end tags of the particular items control. |
|
Items Controls and Visual Trees |
The code method is demonstrated by the ItemsControlsFromCode project. The program is intended to be displayed in a landscape orientation. It instantiates an ItemsControl, a ListBox, and a ComboBox in three columns of the content Grid |
|
The Two Templates : Custom Controls |
If you’re creating controls that need only be used for special purposes in your own applications, the easiest approach is UserControl. Simply define a visual tree for the control in the XAML file. |
|
The Two Templates : The Ever-Handy Thumb |
Thumb derives from Control, defines an IsDragging method, and three events: DragStarted, DragDelta, and DragCompleted. A CancelDrag method lets you abort the process midway through. |
|
The Two Templates : Variations on the Slider |
The Slider has one of the more complex templates in all of standard Silverlight, and for that reason, it’s important to get familiar with it—particularly if you’re not a big fan of the default Slider template implemented in Windows Phone 7. |
|
The Two Templates : Custom Controls in a Library |
Generally when you create a custom control, you define some new properties for the control as well as a default Style and ControlTemplate, and you put that new control in a DLL for sharing among multiple applications. |
|
|
The Two Templates : The Visual State Manager |
All this time that the Button has been redesigned with a template, it has otherwise remained a fully-functional button and it’s been generating Click events every time it’s been tapped. The big problem is that the Button does not deliver visual feedback to the user. It has a customized visual appearance, but that appearance does not change. |
|
The Two Templates : ControlTemplate Basics |
A DataTemplate allows you to customize the display of content in a ContentControl. The ControlTemplate—which you can set to the Template property of any Control—allows you to customize the appearance of the control itself—what’s commonly referred to as the control “chrome.” |
|
The Two Templates : Examining the Visual Tree |
The ButtonTree program lets you dump the visual tree for a rather conventional Button (one with its Content just set to text), a Button with its Content property set to an Image element, and two others with their Content properties set to the RadialGradientBrush and Clock (as shown in the examples above) together with a ContentTemplate. |
|
The Two Templates : ContentControl and DataTemplate |
If the object set to the Content property of a ControlControl does not derive from FrameworkElement, it is rendered with its ToString method, and if the class has no ToString override, the fully-qualified class name is displayed. |
|
Animations : Animations and Property Precedence |
After the animation has concluded, you’ll discover that you can now manipulate the Slider both manually and with the first two buttons. This behavior is not correct and not in accordance with documentation |
|
Animations : Animating Perspective Transforms |
Affine transforms are very well behaved and just a little dull: Straight lines are always transformed to straight lines, ellipses are always transformed to ellipses, and squares are always transformed to parallelograms. |
|
Animations : The Easing Functions |
Defining key frames with splines is easy in one sense—there are only four numbers involved—but also hard: You need to approximate a certain desired effect with a Bézier spline, and that’s not always obvious. |
|
Animations : The Bouncing Ball Problem |
The ball has a TranslateTransform applied to it: the X property is fixed to keep the ball horizontally centered; the Y property is animated between 50 and 600 and back again |
|
Animations : Splines and Key Frames |
Conceptually, during the course of the key frame, the X coordinate of this spline represents normalized time, which changes linearly from 0 to 1. The Y coordinate is the normalized value of the animation, also changing from 0 to 1 but in a non-linear fashion. |
|
|
Animations : Trigger on Loaded |
WPF includes objects called triggers, which respond to event firings or to changes in properties and which can start animations going entirely in XAML, eliminating the need for the code-behind file to start the Storyboard. |
|
Animations : Key Frame Animations |
If you like the idea of giving the user some visual feedback from a button, but the 360° spin is just a bit too ostentatious, perhaps jiggling the button a little might be more polite. |
|
Animations : A Cautionary Tale |
Silverlight has three built-in features that can help you visualize performance issues. Although you can use these on the phone emulator, the emulator tends to run faster than the actual phone, so you’re not getting a true view of performance anyway. |
|
Animations - XAML-Based Animations |
Defining storyboards and animations in XAML is ostensibly easier than defining them in code, and for that reason you’ll find the vast majority of Silverlight storyboards and animations in XAML. |
|
Animations - Some Variations |
The advantage of using strings for property names is that you can stack property names in a pile. This allows you to animate a property of an object without referencing that object itself. |
|
Animations : Click and Spin |
Suppose you want to enhance a button to give some extra visual feedback to the user. You decide you actually want a lot of visual feedback to wake up a drowsy user, and therefore you choose to spin the button around in a circle every time it’s clicked. |
|
Animations : Frame-Based vs. Time-Based |
You can pace this animation either by the rate that video hardware refreshes the display, or by clock time. Because each refresh of the video display is called a frame, these two methods of pacing animation are referred to as frame-based and time-based. |
|