MenuItemBinding.Depth プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > MenuItemBinding.Depth プロパティの意味・解説 

MenuItemBinding.Depth プロパティ

メモ : このプロパティは、.NET Framework version 2.0新しく追加されたものです。

MenuItemBinding オブジェクト適用されるメニュー深さ取得または設定します

名前空間: System.Web.UI.WebControls
アセンブリ: System.Web (system.web.dll 内)
構文構文

解説解説

MenuItemBinding オブジェクト作成する場合バインディング基準指定する必要があります基準は、データ項目をメニュー項目にバインドするタイミング示しますDepth プロパティと DataMember プロパティいずれか、または両方指定できます

Depth プロパティ使用してMenuItemBinding オブジェクト適用するメニュー深さ指定します。たとえば、次の MenuItemBinding 宣言は、データ ソースName フィールドID フィールドを、深さ 0 のすべてのメニュー項目の Text プロパティValue プロパティそれぞれバインドます。

<asp:MenuItemBinding Depth="0" TextField="Name" ValueField="ID">

深さデータ メンバ両方指定するメニュー項目バインディング作成必要になる場合あります。このバインディングは、データ ソース異なレベルで同じデータ メンバ値を持つ項目が含まれている場合によく使用されます。たとえば、1 つXML ファイル内の異なレベル表示される <Item> 要素指定できますメニュー深さ異な同一データ メンバ適用されるメニュー項目バインディング指定方法次の MenuItemBinding 宣言示します

<asp:MenuItemBinding DataMember="Item" Depth="1" TextField="Title">

<asp:MenuItemBinding DataMember="Item" Depth="2" TextField="ISBN">

深さデータ メンバ指定せずにメニュー項目バインディング定義した場合メニュー項目バインディングメニュー内のすべてのメニュー項目に適用されます。これは、通常すべてのデータ項目に同じプロパティ存在しメニュー深さ無関係にまったく同じ表示にする必要がある場合使用されます。

バインディング基準確立されたら、バインド可能な MenuItem オブジェクトプロパティを値にバインドできますデータ項目のフィールドまたは静的な値にバインドできますMenuItemBinding オブジェクト静的な値がバインドされた場合、そのオブジェクト適用先となるすべての MenuItem オブジェクトは、同じ値を共有しますフィールドバインドされるプロパティには、データ ソースフィールドの値が格納されています。

競合する MenuItemBinding オブジェクト定義されている場合Menu コントロール次の優先順位メニュー項目のバインディング適用します。

  1. 深さデータ メンバ両方定義し照合する MenuItemBinding オブジェクト

  2. データ メンバだけを定義し照合する MenuItemBinding オブジェクト

  3. 深さだけを定義し照合する MenuItemBinding オブジェクト

  4. 深さデータ メンバ定義しない MenuItemBinding オブジェクト。この種のメニュー項目バインディングは、メニュー内のすべてのメニュー項目に適用されます。

  5. データ ソース内に一致するものがない MenuItemBinding オブジェクト。この場合データ項目の ToString() メソッドによって返される値は、MenuItemBinding オブジェクト適用されるメニュー項目の Text プロパティValue プロパティバインドされます

使用例使用例

Depth プロパティ使用してMenuItemBinding オブジェクト適用するメニュー深さ指定する方法次のコード例示します。この例を正常に動作させるには、以下のサンプル XML データを、MenuDepth.xml という名前のファイルコピーする必要があります

<%@ page language="VB" %>

<html>
  <body>
    <form runat="server">

      <h3>MenuItemBinding Depth Example</h3>

      <asp:menu id="NavigationMenu"
        datasourceid="MenuSource"
        runat="server">
        
        <databindings>
        
          <asp:menuitembinding depth="0"
            textfield="Title"
            valuefield="Description"
            imageurlfield="ImageUrl"
            tooltipfield="ToolTip"
            target="_self" />
          <asp:menuitembinding depth="1"
            textfield="Title"
            valuefield="Description"
            imageurlfield="ImageUrl"
            tooltipfield="ToolTip"
            target="_blank"/>
          <asp:menuitembinding depth="2"
            textfield="Title"
            valuefield="Description"
            imageurlfield="ImageUrl"
            tooltipfield="ToolTip"
            target="_blank"/>
          
        </databindings>
        
      </asp:menu>

      <asp:xmldatasource id="MenuSource"
        datafile="MenuDepth.xml"
        runat="server"/> 

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

<%@ page language="C#" %>

<html>
  <body>
    <form runat="server">

      <h3>MenuItemBinding Depth Example</h3>

      <asp:menu id="NavigationMenu"
        datasourceid="MenuSource"
        runat="server">
        
        <databindings>
        
          <asp:menuitembinding depth="0"
            textfield="Title"
            valuefield="Description"
            imageurlfield="ImageUrl"
            tooltipfield="ToolTip"
            target="_self" />
          <asp:menuitembinding depth="1"
            textfield="Title"
            valuefield="Description"
            imageurlfield="ImageUrl"
            tooltipfield="ToolTip"
            target="_blank"/>
          <asp:menuitembinding depth="2"
            textfield="Title"
            valuefield="Description"
            imageurlfield="ImageUrl"
            tooltipfield="ToolTip"
            target="_blank"/>
          
        </databindings>
        
      </asp:menu>

      <asp:xmldatasource id="MenuSource"
        datafile="MenuDepth.xml"
        runat="server"/> 

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

前の例のサンプル サイト マップ データ次のコード示します

<MapNode ImageUrl="~\Images\Home.gif"

Title="Home"

Description="Root Page"

ToolTip="Home Page">

<MapNode ImageUrl="~\Images\Music.gif"

Title="Music"

Description="Music Category"

ToolTip="Music Page">

<MapNode ImageUrl="~\Images\Classical.gif"

Title="Classical"

Description="Classical Section"

ToolTip="Classical Page"/>

<MapNode ImageUrl="~\Images\Rock.gif"

Title="Rock"

Description="Rock Section"

ToolTip="Rock Page"/>

<MapNode ImageUrl="~\Images\Jazz.gif"

Title="Jazz"

Description="Jazz Section"

ToolTip="Jazz Page"/>

</MapNode>

<MapNode ImageUrl="~\Images\Movies.gif"

Title="Movies"

Description="Movies Category"

ToolTip="Movies Page">

<MapNode ImageUrl="~\Images\Action.gif"

Title="Action"

Description="Action Section"

ToolTip="Action Page"/>

<MapNode ImageUrl="~\Images\Drama.gif"

Title="Drama"

Description="Drama Section"

ToolTip="Drama Page"/>

<MapNode ImageUrl="~\Images\Musical.gif"

Title="Musical"

Description="Musical Section"

ToolTip="Musical Page"/>

</MapNode>

</MapNode>

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
MenuItemBinding クラス
MenuItemBinding メンバ
System.Web.UI.WebControls 名前空間
Menu クラス
MenuItem クラス
MenuItemBindingCollection
Menu.DataBindings プロパティ
MenuItemBinding.DataMember プロパティ
MenuItem.Depth プロパティ


このページでは「.NET Framework クラス ライブラリ リファレンス」からMenuItemBinding.Depth プロパティを検索した結果を表示しています。
Weblioに収録されているすべての辞書からMenuItemBinding.Depth プロパティを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からMenuItemBinding.Depth プロパティ を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「MenuItemBinding.Depth プロパティ」の関連用語

MenuItemBinding.Depth プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



MenuItemBinding.Depth プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS