Style 类

定义

警告

此 API 现已过时。

组织 ASP.NET 移动控件的样式特性。Organizes style characteristics of an ASP.NET mobile control. 若要了解如何开发 ASP.NET 移动应用,请参阅 ASP.NET 移动应用和网站For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET.

public ref class Style : ICloneable, System::Web::UI::IParserAccessor, System::Web::UI::IStateManager, System::Web::UI::MobileControls::ITemplateable
[System.ComponentModel.TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
[System.Obsolete("The System.Web.Mobile.dll assembly has been deprecated and should no longer be used. For information about how to develop ASP.NET mobile applications, see http://go.microsoft.com/fwlink/?LinkId=157231.")]
public class Style : ICloneable, System.Web.UI.IParserAccessor, System.Web.UI.IStateManager, System.Web.UI.MobileControls.ITemplateable
type Style = class
    interface IParserAccessor
    interface ITemplateable
    interface IStateManager
    interface ICloneable
Public Class Style
Implements ICloneable, IParserAccessor, IStateManager, ITemplateable
继承
Style
派生
属性
实现

示例

下面的示例演示了 StyleSheet 对象中三个用户定义的样式。The following example demonstrates three user-defined styles in a StyleSheet object. SelectionList 对象包含三个对应于三个已定义的样式的值。A SelectionList object holds three values that correspond to the three defined styles. OnClick 命令事件将调用 SelectStyle 函数,该函数将更改 TextView 对象的 StyleReference 属性。The OnClick command event calls the SelectStyle function, which changes the StyleReference property of the TextView object.

<%@ Page Language="C#" 
    Inherits="System.Web.UI.MobileControls.MobilePage" %>
<%@ Register TagPrefix="mobile" 
    Namespace="System.Web.UI.MobileControls" 
    Assembly="System.Web.Mobile" %>

<script runat="server">
    void SelectStyle(object sender, EventArgs e)
    {
        // Retrieve the style name as a string.
        String myStyle = SelectionList1.Selection.ToString();
        // Match the style name and apply the style to TextView1.
        switch (myStyle)
        {
            case "hot":
                TextView1.StyleReference = "Style1";
                break;
            case "medium":
                TextView1.StyleReference = "Style2";
                break;
            case "mild":
                TextView1.StyleReference = "Style3";
                break;
        }
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<body>
<mobile:StyleSheet id="StyleSheet1" runat="server">
    <mobile:Style font-size="Large" font-name="Arial" font-bold="true"
        forecolor="red" font-italic="true" backcolor="#E0E0E0" 
        wrapping="wrap" name="Style1">
    </mobile:Style>
    <mobile:Style font-size="Normal" font-name="Arial" font-bold="false" 
       forecolor="Blue" font-italic="true" backcolor="blue" 
       wrapping="NoWrap" name="Style2">
    </mobile:Style>
    <mobile:Style font-size="Small" font-name="Arial Narrow" 
       font-bold="false" forecolor="Green" font-italic="false" 
       backcolor="Green" wrapping="NoWrap" name="Style3">
    </mobile:Style>
</mobile:StyleSheet>
<mobile:form id="Form1" runat="server">
    <mobile:Label id="Label1" runat="server" Text="Today's Special" 
        StyleReference="title" />
    <mobile:TextView id="TextView1" runat="server" 
        StyleReference="Style1">
        Chili
    </mobile:TextView>
    <mobile:SelectionList runat="server" id="SelectionList1">
        <item Text="hot" Value="hot"/>
        <item Text="medium" Value="medium"/>
        <item Text="mild" Value="mild"/>
    </mobile:SelectionList>
    <mobile:Command runat="server" Text="Select Style" 
        OnClick="SelectStyle" />
    </mobile:form>
</body>
</html>
<%@ Page Language="VB" 
    Inherits="System.Web.UI.MobileControls.MobilePage" %>
<%@ Register TagPrefix="mobile" 
    Namespace="System.Web.UI.MobileControls" 
    Assembly="System.Web.Mobile" %>

<script runat="server">
    Private Sub SelectStyle(ByVal sender As Object, _
        ByVal e As EventArgs)
        
        ' Retrieve the style name as a string
        Dim myStyle As String = SelectionList1.Selection.ToString()
        ' Match the style name and apply the style to TextView1
        Select Case myStyle
            Case "hot"
                TextView1.StyleReference = "Style1"
            Case "medium"
                TextView1.StyleReference = "Style2"
            Case "mild"
                TextView1.StyleReference = "Style3"
        End Select
    End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<body>
<mobile:StyleSheet id="StyleSheet1" runat="server">
    <mobile:Style font-size="Large" font-name="Arial" font-bold="true"
        forecolor="red" font-italic="true" backcolor="#E0E0E0" 
        wrapping="wrap" name="Style1">
    </mobile:Style>
    <mobile:Style font-size="Normal" font-name="Arial" font-bold="false" 
       forecolor="Blue" font-italic="true" backcolor="blue" 
       wrapping="NoWrap" name="Style2">
    </mobile:Style>
    <mobile:Style font-size="Small" font-name="Arial Narrow" 
       font-bold="false" forecolor="Green" font-italic="false" 
       backcolor="Green" wrapping="NoWrap" name="Style3">
    </mobile:Style>
</mobile:StyleSheet>

<mobile:form id="Form1" runat="server">
    <mobile:Label id="Label1" runat="server" Text="Today's Special" 
        StyleReference="title" />
    <mobile:TextView id="TextView1" runat="server" 
        StyleReference="Style1">
        Chili
    </mobile:TextView>
    <mobile:SelectionList runat="server" id="SelectionList1">
        <item Text="hot" Value="hot"/>
        <item Text="medium" Value="medium"/>
        <item Text="mild" Value="mild"/>
    </mobile:SelectionList>
    <mobile:Command ID="Command1" runat="server" Text="Select Style" 
        OnClick="SelectStyle" />
    </mobile:form>
</body>
</html>

注解

Base Style 类包含所有移动控件通用的样式特性。The base Style class contains style characteristics common to all mobile controls. Style 类继承的类包含特定于其关联控件的其他样式特性。Classes that inherit from the Style class contain additional style characteristics specific to their associated control.

由于移动控件支持的设备多样性,所有样式属性均为建议,并且根据目标设备的功能,可能会也可能不遵守。Due to the diversity of devices supported by mobile controls, all style properties are advisory, and might or might not be honored depending on the capabilities of the target device.

构造函数

Style()

初始化 Style 类的新实例。Initializes a new instance of the Style class. 此 API 已过时。This API is obsolete. 若要了解如何开发 ASP.NET 移动应用,请参阅 ASP.NET 移动应用和网站For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET.

字段

AlignmentKey

表示用于检索 AlignmentStyle 设置的键。Represents the key used to retrieve the Alignment setting of the Style. 此 API 已过时。This API is obsolete. 若要了解如何开发 ASP.NET 移动应用,请参阅 ASP.NET 移动应用和网站For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET.

BackColorKey

用于从 BackColor 属性的嵌入式样式表中检索样式的键。The key for retrieving the style from the embedded style sheet for BackColor property. 由 ASP.NET 在内部使用。Used internally by ASP.NET. 此 API 已过时。This API is obsolete. 若要了解如何开发 ASP.NET 移动应用,请参阅 ASP.NET 移动应用和网站For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET.

BoldKey

用于从 BoldFont 属性的嵌入式样式表中检索样式的键。The key for retrieving the style from the embedded style sheet for setting the Bold property of the Font. 由 ASP.NET 在内部使用。Used internally by ASP.NET. 此 API 已过时。This API is obsolete. 若要了解如何开发 ASP.NET 移动应用,请参阅 ASP.NET 移动应用和网站For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET.

FontNameKey

用于从 Name 属性的 Font 属性的嵌入式样式表中检索样式的键。The key for retrieving the style from the embedded style sheet for the Name property of the Font property. 由 ASP.NET 在内部使用。Used internally by ASP.NET. 此 API 已过时。This API is obsolete. 若要了解如何开发 ASP.NET 移动应用,请参阅 ASP.NET 移动应用和网站For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET.

FontSizeKey

用于从 Size 属性的 Font 属性的嵌入式样式表中检索样式的键。The key for retrieving the style from the embedded style sheet for the Size property of the Font property. 由 ASP.NET 在内部使用。Used internally by ASP.NET. 此 API 已过时。This API is obsolete. 若要了解如何开发 ASP.NET 移动应用,请参阅 ASP.NET 移动应用和网站For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET.

ForeColorKey

用于从 ForeColor 属性的嵌入式样式表中检索样式的键。The key for retrieving the style from the embedded style sheet for the ForeColor property. 由 ASP.NET 在内部使用。Used internally by ASP.NET. 此 API 已过时。This API is obsolete. 若要了解如何开发 ASP.NET 移动应用,请参阅 ASP.NET 移动应用和网站For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET.

ItalicKey

用于从 Italic 属性的 Font 属性的嵌入式样式表中检索样式的键。The key for retrieving the style from the embedded style sheet for the Italic property of the Font property. 由 ASP.NET 在内部使用。Used internally by ASP.NET. 此 API 已过时。This API is obsolete. 若要了解如何开发 ASP.NET 移动应用,请参阅 ASP.NET 移动应用和网站For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET.

WrappingKey

用于从 Wrapping 的嵌入式样式表中检索样式的键。The key for retrieving the style from the embedded style sheet for Wrapping. 由 ASP.NET 在内部使用。Used internally by ASP.NET. 此 API 已过时。This API is obsolete. 若要了解如何开发 ASP.NET 移动应用,请参阅 ASP.NET 移动应用和网站For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET.

属性

Alignment

获取或设置样式的指定对齐方式。Gets or sets the specified alignment for the style. 默认值为 NotSetThe default value is NotSet. 此 API 已过时。This API is obsolete. 若要了解如何开发 ASP.NET 移动应用,请参阅 ASP.NET 移动应用和网站For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET.

BackColor

获取或设置样式的指定背景色。Gets or sets the specified background color for the style. 默认值为 EmptyThe default value is Empty. 此 API 已过时。This API is obsolete. 若要了解如何开发 ASP.NET 移动应用,请参阅 ASP.NET 移动应用和网站For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET.

Control

返回一个对关联控件的强类型引用。Returns a strongly typed reference to the associated control. 此 API 已过时。This API is obsolete. 若要了解如何开发 ASP.NET 移动应用,请参阅 ASP.NET 移动应用和网站For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET.

DeviceSpecific

获取或设置与控件关联的 DeviceSpecific/Choice 构造。Gets or sets the DeviceSpecific/Choice construct associated with the control. 如果不存在此类构造,则访问器返回 nullThe accessor returns null if no such construct exists. 此 API 已过时。This API is obsolete. 若要了解如何开发 ASP.NET 移动应用,请参阅 ASP.NET 移动应用和网站For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET.

Font

返回包含有关控件字体信息的 FontInfo 对象。Returns a FontInfo object that contains font information about the control. 此 API 已过时。This API is obsolete. 若要了解如何开发 ASP.NET 移动应用,请参阅 ASP.NET 移动应用和网站For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET.

ForeColor

获取或设置样式的指定前景色。Gets or sets the specified foreground color for the style. 此属性通常用于设置文本颜色。Typically, this property sets the color for the text. 默认值为 EmptyThe default value is Empty. 此 API 已过时。This API is obsolete. 若要了解如何开发 ASP.NET 移动应用,请参阅 ASP.NET 移动应用和网站For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET.

IsTemplated

获取一个值,该值指示 Style 对象是否有活动的模板集。Gets a value indicating whether a Style object has an active template set. 此 API 已过时。This API is obsolete. 若要了解如何开发 ASP.NET 移动应用,请参阅 ASP.NET 移动应用和网站For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET.

IsTrackingViewState

获取一个值,该值指示 Style 对象是否保存对其视图状态的更改。Gets a value indicating whether the Style object is saving changes to its view state. 此 API 已过时。This API is obsolete. 若要了解如何开发 ASP.NET 移动应用,请参阅 ASP.NET 移动应用和网站For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET.

Item[Object, Boolean]

通过键参数返回样式(可以使用也可以不使用继承)。Returns the style, through the key parameter, with or without using inheritance. 此 API 已过时。This API is obsolete. 若要了解如何开发 ASP.NET 移动应用,请参阅 ASP.NET 移动应用和网站For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET.

Item[Object]

通过键参数返回样式(可以使用也可以不使用继承)。Returns the style through the key parameter, with or without using inheritance. 此 API 已过时。This API is obsolete. 若要了解如何开发 ASP.NET 移动应用,请参阅 ASP.NET 移动应用和网站For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET.

Name

获取或设置指定对象的名称。Gets or sets the name of the specified object. 默认值为空字符串 ("")。The default value is an empty string (""). 此 API 已过时。This API is obsolete. 若要了解如何开发 ASP.NET 移动应用,请参阅 ASP.NET 移动应用和网站For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET.

State

获取 StateBag 的当前内容。Gets the current contents of the StateBag. 此 API 已过时。This API is obsolete. 若要了解如何开发 ASP.NET 移动应用,请参阅 ASP.NET 移动应用和网站For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET.

StyleReference

获取或设置对 Style 的样式属性的引用。Gets or sets a reference to the style properties for a Style. 此 API 已过时。This API is obsolete. 若要了解如何开发 ASP.NET 移动应用,请参阅 ASP.NET 移动应用和网站For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET.

Wrapping

获取或设置样式的指定包装模式。Gets or sets the specified wrapping mode for the style. 默认值为 NotSetThe default value is NotSet. 此 API 已过时。This API is obsolete. 若要了解如何开发 ASP.NET 移动应用,请参阅 ASP.NET 移动应用和网站For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET.

方法

AddParsedSubObject(Object)

DeviceSpecific 属性设置为指定的对象。Sets the DeviceSpecific property to the specified object. 此 API 已过时。This API is obsolete. 若要了解如何开发 ASP.NET 移动应用,请参阅 ASP.NET 移动应用和网站For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET.

ApplyTo(WebControl)

将样式属性应用到控件。Applies the properties of a style to a control. 此 API 已过时。This API is obsolete. 若要了解如何开发 ASP.NET 移动应用,请参阅 ASP.NET 移动应用和网站For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET.

Clone()

返回此 Style 对象的实例的一个副本。Returns a copy of this instance of the Style object. 此 API 已过时。This API is obsolete. 若要了解如何开发 ASP.NET 移动应用,请参阅 ASP.NET 移动应用和网站For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET.

Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetHashCode()

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetTemplate(String)

返回具有指定名称的模板。Returns the template with the specified name. 此 API 已过时。This API is obsolete. 若要了解如何开发 ASP.NET 移动应用,请参阅 ASP.NET 移动应用和网站For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET.

GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
LoadViewState(Object)

将视图状态加载到 State 对象的 Style 中。Loads the view state into the State of the Style object. 此 API 已过时。This API is obsolete. 若要了解如何开发 ASP.NET 移动应用,请参阅 ASP.NET 移动应用和网站For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET.

MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
RegisterStyle(String, Type, Object, Boolean)

注册一个样式属性并返回一个用于查找的唯一键。Registers a style property and returns a unique key for lookup. 此 API 已过时。This API is obsolete. 若要了解如何开发 ASP.NET 移动应用,请参阅 ASP.NET 移动应用和网站For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET.

SaveViewState()

将对视图状态的更改保存到 ObjectSaves the changes to the view state to an Object. 此 API 已过时。This API is obsolete. 若要了解如何开发 ASP.NET 移动应用,请参阅 ASP.NET 移动应用和网站For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET.

ToString()

返回一个表示当前对象的 string。Returns a string that represents the current object.

(继承自 Object)
TrackViewState()

打开 Style 对象中的视图状态跟踪。Turns on the tracking of view state in the Style object. 此 API 已过时。This API is obsolete. 若要了解如何开发 ASP.NET 移动应用,请参阅 ASP.NET 移动应用和网站For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET.

显式接口实现

IParserAccessor.AddParsedSubObject(Object)

有关此成员的说明,请参见 AddParsedSubObject(Object)For a description of this member, see AddParsedSubObject(Object). 此 API 已过时。This API is obsolete. 若要了解如何开发 ASP.NET 移动应用,请参阅 ASP.NET 移动应用和网站For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET.

IStateManager.IsTrackingViewState

有关此成员的说明,请参见 IsTrackingViewStateFor a description of this member, see IsTrackingViewState. 此 API 已过时。This API is obsolete. 若要了解如何开发 ASP.NET 移动应用,请参阅 ASP.NET 移动应用和网站For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET.

IStateManager.LoadViewState(Object)

有关此成员的说明,请参见 LoadViewState(Object)For a description of this member, see LoadViewState(Object). 此 API 已过时。This API is obsolete. 若要了解如何开发 ASP.NET 移动应用,请参阅 ASP.NET 移动应用和网站For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET.

IStateManager.SaveViewState()

有关此成员的说明,请参见 SaveViewState()For a description of this member, see SaveViewState(). 此 API 已过时。This API is obsolete. 若要了解如何开发 ASP.NET 移动应用,请参阅 ASP.NET 移动应用和网站For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET.

IStateManager.TrackViewState()

有关此成员的说明,请参见 TrackViewState()For a description of this member, see TrackViewState(). 此 API 已过时。This API is obsolete. 若要了解如何开发 ASP.NET 移动应用,请参阅 ASP.NET 移动应用和网站For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET.

安全性

AspNetHostingPermission
用于在宿主环境中进行操作。for operating in a hosted environment. 要求值:InheritanceDemand;权限值:MinimalDemand value: InheritanceDemand; Permission value: Minimal.

适用于

另请参阅