MenuItemBinding.Depth プロパティ
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
MenuItemBinding オブジェクトが適用されるメニューの深さを取得または設定します。
public:
property int Depth { int get(); void set(int value); };
[System.ComponentModel.TypeConverter("System.Web.UI.Design.WebControls.TreeNodeBindingDepthConverter, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public int Depth { get; set; }
[System.ComponentModel.TypeConverter("System.Web.UI.Design.WebControls.TreeNodeBindingDepthConverter, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public int Depth { get; set; }
[<System.ComponentModel.TypeConverter("System.Web.UI.Design.WebControls.TreeNodeBindingDepthConverter, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")>]
member this.Depth : int with get, set
[<System.ComponentModel.TypeConverter("System.Web.UI.Design.WebControls.TreeNodeBindingDepthConverter, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")>]
member this.Depth : int with get, set
Public Property Depth As Integer
プロパティ値
MenuItemBinding オブジェクトが適用されるメニューの深さ。 既定値は -1 です。このプロパティが設定されていないことを示します。
- 属性
例
次のコード例では、 プロパティを使用 Depth して、オブジェクトを適用するメニューの深さを指定する方法を MenuItemBinding 示します。 この例を正しく機能させるには、以下のサンプル XML データを MenuDepth.xml という名前のファイルにコピーする必要があります。
<%@ 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>MenuItemBinding Depth Example</title>
</head>
<body>
<form id="form1" 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="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>MenuItemBinding Depth Example</title>
</head>
<body>
<form id="form1" 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 、バインドの条件を指定する必要があります。 条件は、データ項目をメニュー項目にバインドする必要があるタイミングを示します。 プロパティ、プロパティ、またはその両方をDataMember指定Depthできます。
オブジェクトを Depth 適用するメニューの深さを指定するには、 プロパティを MenuItemBinding 使用します。 たとえば、次 MenuItemBinding の宣言では、データ ソースの Name フィールドと ID フィールドをそれぞれ Text 、深さが 0 のすべてのメニュー項目の プロパティと Value プロパティにバインドします。
<asp:MenuItemBinding Depth="0" TextField="Name" ValueField="ID">
場合によっては、深度とデータ メンバーの両方を指定するメニュー項目バインドを作成する必要がある場合があります。 これは、データ ソースに同じデータ メンバー値を持つ異なるレベルのアイテムが含まれている場合によく使用されます。 たとえば、XML ファイル内のさまざまなレベルに表示される要素を含めることができます <Item>
。 次 MenuItemBinding の宣言は、異なるメニューの深さで同じデータ メンバーに適用されるメニュー項目バインドを指定する方法を示しています。
<asp:MenuItemBinding DataMember="Item" Depth="1" TextField="Title">
<asp:MenuItemBinding DataMember="Item" Depth="2" TextField="ISBN">
メニュー項目バインドが深度とデータ メンバーなしで定義されている場合、メニュー項目バインドはメニュー内のすべてのメニュー項目に適用されます。 これは、すべてのデータ項目が同じプロパティを持ち、メニューの深さに関係なく同じように表示する必要がある場合に一般的に使用されます。
バインド条件が確立されたら、値にバインドできるオブジェクトの MenuItem プロパティをバインドできます。 データ項目のフィールドまたは静的な値にバインドできます。 静的な値にバインドすると、そのオブジェクトがMenuItemBinding適用されるすべてのMenuItemオブジェクトが同じ値を共有します。 フィールドにバインドされたプロパティには、データ ソースのフィールドの値が含まれます。
競合する MenuItemBinding オブジェクトが定義されている場合、コントロールは Menu メニュー項目のバインドを次の優先順位で適用します。
MenuItemBinding深度とデータ メンバーの両方を定義し、一致する オブジェクト。
MenuItemBindingデータ メンバーのみを定義し、一致する オブジェクト。
MenuItemBinding深度のみを定義し、一致する オブジェクト。
MenuItemBinding深度もデータ メンバーも定義しない オブジェクト。 (この種類のメニュー項目バインドは、メニュー内のすべてのメニュー項目に適用されます)。
MenuItemBindingデータ ソースに一致しない オブジェクト。 この場合、データ項目の メソッドによって
ToString()
返される値は、オブジェクトが適用されるメニュー項目の プロパティと Value プロパティにMenuItemBindingバインドTextされます。