Menu.LevelSubMenuStyles 屬性

定義

取得 MenuItemStyleCollection 物件,這個物件含有根據 Menu 控制項中的子功能表項目層級,套用至靜態功能表中子功能表項目的樣式設定。Gets a MenuItemStyleCollection object that contains the style settings that are applied to the submenu items in the static menu based on their level in a Menu control.

public:
 property System::Web::UI::WebControls::SubMenuStyleCollection ^ LevelSubMenuStyles { System::Web::UI::WebControls::SubMenuStyleCollection ^ get(); };
[System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)]
public System.Web.UI.WebControls.SubMenuStyleCollection LevelSubMenuStyles { get; }
[<System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)>]
member this.LevelSubMenuStyles : System.Web.UI.WebControls.SubMenuStyleCollection
Public ReadOnly Property LevelSubMenuStyles As SubMenuStyleCollection

屬性值

SubMenuStyleCollection

MenuItemStyleCollection,含有根據 Menu 控制項中的子功能表項目層級,套用至靜態功能表中子功能表項目的樣式設定。A MenuItemStyleCollection that contains the style settings that are applied to the submenu items in the static menu based on their level in a Menu control.

屬性

範例

下列程式碼範例示範如何使用 LevelSubMenuStyles 集合,將樣式設定套用至控制項的靜態功能表中顯示的子功能表專案( Menu 根據其層級)。The following code example demonstrates how to use the LevelSubMenuStyles collection to apply style settings to the submenu items displayed in the static menu of a Menu control based on their level.


<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>Menu LevelSubMenuStyles</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>Menu LevelSubMenuStyles</h3>

      <asp:menu id="NavigationMenu"
        staticdisplaylevels="3"
        staticsubmenuindent="10" 
        orientation="Vertical"
        target="_blank"  
        runat="server">
        
        <levelsubmenustyles>
          <asp:submenustyle backcolor="LightSteelBlue"
            forecolor="Black"/>
          <asp:submenustyle backcolor="SkyBlue"
            forecolor="Gray"/>          
        </levelsubmenustyles>  
      
        <items>
          <asp:menuitem text="Home"
            tooltip="Home">
            <asp:menuitem text="Music"
              tooltip="Music">
              <asp:menuitem text="Classical"
                tooltip="Classical"/>
              <asp:menuitem text="Rock"
                tooltip="Rock"/>
              <asp:menuitem text="Jazz"
                tooltip="Jazz"/>
            </asp:menuitem>
            <asp:menuitem text="Movies"
              tooltip="Movies">
              <asp:menuitem text="Action"
                tooltip="Action"/>
              <asp:menuitem text="Drama"
                tooltip="Drama"/>
              <asp:menuitem text="Musical"
                tooltip="Musical"/>
            </asp:menuitem>
          </asp:menuitem>
        </items>
      
      </asp:menu>

    </form>
  </body>
</html>


<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>Menu LevelSubMenuStyles</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>Menu LevelSubMenuStyles</h3>

      <asp:menu id="NavigationMenu"
        staticdisplaylevels="3"
        staticsubmenuindent="10" 
        orientation="Vertical"
        target="_blank"  
        runat="server">
        
        <levelsubmenustyles>
          <asp:submenustyle backcolor="LightSteelBlue"
            forecolor="Black"/>
          <asp:submenustyle backcolor="SkyBlue"
            forecolor="Gray"/>          
        </levelsubmenustyles>  
      
        <items>
          <asp:menuitem text="Home"
            tooltip="Home">
            <asp:menuitem text="Music"
              tooltip="Music">
              <asp:menuitem text="Classical"
                tooltip="Classical"/>
              <asp:menuitem text="Rock"
                tooltip="Rock"/>
              <asp:menuitem text="Jazz"
                tooltip="Jazz"/>
            </asp:menuitem>
            <asp:menuitem text="Movies"
              tooltip="Movies">
              <asp:menuitem text="Action"
                tooltip="Action"/>
              <asp:menuitem text="Drama"
                tooltip="Drama"/>
              <asp:menuitem text="Musical"
                tooltip="Musical"/>
            </asp:menuitem>
          </asp:menuitem>
        </items>
      
      </asp:menu>

    </form>
  </body>
</html>

備註

使用 LevelSubMenuStyles 集合做為個別樣式屬性的替代專案 (例如 StaticMenuItemStyle) ,以控制在個別層級的靜態功能表中所顯示之靜態子功能表項的樣式。Use the LevelSubMenuStyles collection as an alternative to the individual style properties (such as StaticMenuItemStyle) to control the style of the static submenu items displayed in the static menu at the individual levels. 此集合中包含的樣式會根據其功能表層級套用至靜態子功能表專案。The styles contained in this collection are applied to the static submenu items based on their menu level. 集合中的第一個樣式會對應至靜態功能表中所顯示的第一個靜態子功能表層級的樣式。The first style in the collection corresponds to the style of the first static submenu level displayed in the static menu. 集合中的第二個樣式會對應至 [靜態] 功能表中顯示之第二個子功能表層級的樣式,依此類推。The second style in the collection corresponds to the style of the second submenu level displayed in the static menu, and so on. 這個集合最常用來產生目錄樣式的導覽功能表,其中特定層級的功能表項目應該具有相同的外觀,不論它們是否有子功能表。This collection is most often used to generate table of contents-style navigation menus where menu items at a certain level should have the same appearance, regardless of whether they have submenus.

注意

如果使用集合為特定層級定義樣式,則會 LevelSubMenuStyles 覆寫該層級的任何靜態子功能表專案樣式設定。If a style is defined for a certain level using the LevelSubMenuStyles collection, this overrides any static submenu item style settings at that level.

適用於

另請參閱