|
I’m about to release a tutorial and a few videos on Styles and Templates. To set the stage, I wanted to discuss one aspect of templating in Silverlight that is in some ways revolutionary. The designers of the Silverlight 2 control libraries established from the outset that there would be an absolute decoupling of the control logic (as implemented by event handlers) from the User Interface . This allows the UI to be dictated entirely by Tempolates, (and the Visual State Machine) and in turn that allows templates to be written entirely in Xaml and to consist of a combination of graphic primitives and story boards (transitions). This means that every control is lookless . The appearance of all the controls in the toolbox is just the appearance provided by the “out of the box” template assigned to it by the control creator. It has no more intrinsic validity than any other skin you might put on the control. Say what? That means you are absolutely and 100% free to use the button as is, or to make it look like a dog, and have it bark when pressed. Or, consider the images shown here. Both sets show buttons being before and after being clicked. Other than aesthetics and convention, there is nothing that makes one set more correct than the other. The Possible States are Defined and Embedded in Metadata Both “looks” are equally valid, and both buttons send exactly the same click event. Since the designer of the out of the box button was kind enough to embed all the button’s state information in the button’s meta-data (e.g., “I have the states Normal, MouseOver, MouseDown, Disabled, Focus and NotFocused), and since Expression Blend reads that meta data and makes editing the appearance and behavior astonishingly easy, it is not only valid to change it to a round, spinning, dipping shape, it is (to be honest) fun. Three Ways To Modify Controls As you will see in the tutorial to be release within the next day or so, I distinguish among three ways to modify the look of a control: 1. “In line” attributes 2. Style objects 3. Templates In Line Attributes Very briefly, the first of these we all do all the time. This is as simple as adding such UI controlling attributes as HorizontalAlignment="Left" to the Xaml. It is fielder’s choice as to whether you set these attributes directly in Xaml or let Blend set them for you as you create your UI Styles The second is a more formal approach in which you create a Style object that can...
|