Accessing Style Properties in Device Adapters
All ASP.NET mobile controls support style properties for rendering, such as font, color, and alignment. Style properties are handled differently for each mobile device, so each adapter has a different implementation for style rendering.
All mobile controls have an associated style object that contains style properties directly defined for the control. The style object must be an instance of a class that inherits from System.Web.UI.MobileControls.Style.
The style object is defined as a protected field of the MobileControl base class, and is thus hidden from the page developer. However, for each property of a style object, the associated control class also exposes a public property that can be read or written. For example, the MobileControl base class exposes all the properties of the Style base class as its own. In addition, styles follow the inheritance model. At rendering time, control adapters can get style information that includes inherited values, using a special indexer on the style.
Accessing Style Properties in Control Adapters
To use style properties in rendering, control adapters can access the style object associated with the control. The control adapter base class provides a Style property that can be used to access the control's style object. However, adapters must use a different accessor function to get style properties, so that style inheritance behavior can be applied. To facilitate this, the Style base class provides an additional indexer property that takes two parameters, the property key and a Boolean argument to specify whether inheritance should be applied.
For example, the following code accesses the font name by using the FontNameKey and ThemeName fields of a control, and sets inheritance to true.
[C#]
String fontName = MyStyle[Style.FontNameKey, true];
String themeName = Style[MyStyle.ThemeNameKey, true];
See Also
Walkthrough: Implementing a New Style | <Style> element | Style Class Members | Stylesheet control | Stylesheet Class