Menu.LevelSelectedStyles Özellik

Tanım

MenuItemStyleCollection Denetimdeki düzeyine göre seçili menü öğesine uygulanan stil ayarlarını içeren bir Menu nesneyi alır.

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

Özellik Değeri

MenuItemStyleCollection

Denetimdeki MenuItemStyleCollection düzeyine göre seçili menü öğesine uygulanan stil ayarlarını içeren.Menu

Öznitelikler

Örnekler

Aşağıdaki kod örneği, düzeyine göre bir denetimdeki LevelSelectedStyles seçili menü öğesine Menu stil ayarı uygulamak için koleksiyonun nasıl kullanılacağını gösterir.


<%@ 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 LevelMenuItemStyles and LevelSelectedStyles Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>Menu LevelMenuItemStyles and LevelSelectedStyles Example</h3>

      <asp:menu id="NavigationMenu"
        staticdisplaylevels="2"
        staticsubmenuindent="10" 
        orientation="Vertical"
        target="_blank"  
        runat="server">
        
        <levelmenuitemstyles>
          <asp:menuitemstyle BackColor="LightSteelBlue"
            forecolor="Black"/>
          <asp:menuitemstyle BackColor="SkyBlue"
            forecolor="Black"/>
          <asp:menuitemstyle BackColor="LightSkyBlue"
            forecolor="Black"/>            
        </levelmenuitemstyles>
        <levelselectedstyles>
          <asp:menuitemstyle BackColor="Cyan"
           forecolor="Gray"/>
          <asp:menuitemstyle BackColor="LightCyan"
           forecolor="Gray"/>
          <asp:menuitemstyle BackColor="PaleTurquoise"
           forecolor="Gray"/>            
        </levelselectedstyles>    
      
        <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 LevelMenuItemStyles and LevelSelectedStyles Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>Menu LevelMenuItemStyles and LevelSelectedStyles Example</h3>

      <asp:menu id="NavigationMenu"
        staticdisplaylevels="2"
        staticsubmenuindent="10" 
        orientation="Vertical"
        target="_blank"  
        runat="server">
        
        <levelmenuitemstyles>
          <asp:menuitemstyle BackColor="LightSteelBlue"
            forecolor="Black"/>
          <asp:menuitemstyle BackColor="SkyBlue"
            forecolor="Black"/>
          <asp:menuitemstyle BackColor="LightSkyBlue"
            forecolor="Black"/>            
        </levelmenuitemstyles>
        <levelselectedstyles>
          <asp:menuitemstyle BackColor="Cyan"
           forecolor="Gray"/>
          <asp:menuitemstyle BackColor="LightCyan"
           forecolor="Gray"/>
          <asp:menuitemstyle BackColor="PaleTurquoise"
           forecolor="Gray"/>            
        </levelselectedstyles>    
      
        <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>

Açıklamalar

Seçili menü öğesinin LevelSelectedStyles stilini menünün ayrı düzeylerinde denetlemek için ve StaticSelectedStyle özelliklerine alternatif DynamicSelectedStyle olarak koleksiyonu kullanın. Bu koleksiyonda yer alan stiller, menü düzeyine göre seçili bir menü öğesine uygulanır. Koleksiyondaki ilk stil, menünün ilk düzeyindeki seçili menü öğesinin stiline karşılık gelir. Koleksiyondaki ikinci stil, menünün ikinci düzeyinde seçili bir menü öğesinin stiline karşılık gelir ve bu şekilde devam eder. Bu koleksiyon çoğunlukla, alt menüleri olup olmadığına bakılmaksızın belirli bir düzeydeki menü öğelerinin aynı görünüme sahip olması gereken içindekiler stilinde gezinti menüleri oluşturmak için kullanılır.

Not

Koleksiyon kullanılarak LevelSelectedStyles belirli bir düzey için bir stil tanımlanmışsa, bu, bu düzeydeki DynamicSelectedStyle ve StaticSelectedStyle özelliklerini geçersiz kılar.

Şunlara uygulanır

Ayrıca bkz.