语言

ToolBar.BandIndex 属性

定义

获取或设置指示工具栏在带上的位置的带索引号。

public:
 property int BandIndex { int get(); void set(int value); };
public int BandIndex { get; set; }
member this.BandIndex : int with get, set
Public Property BandIndex As Integer

属性值

工具栏在某一 ToolBarTray带上的位置。

示例

以下示例演示如何使用此属性将控件置于 ToolBar 其中 ToolBarTray。

<ToolBarTray Background="White">
  <ToolBar Band="1" BandIndex="1">
    <Button>
      <Image Source="toolbargraphics\cut.bmp" />
    </Button>
    <Button>
      <Image Source="toolbargraphics\copy.bmp" />
    </Button>
    <Button>
      <Image Source="toolbargraphics\paste.bmp" />
    </Button>
  </ToolBar>
  <ToolBar Band="2" BandIndex="1">
    <Button>
      <Image Source="toolbargraphics\undo.bmp" />
    </Button>
    <Button>
      <Image Source="toolbargraphics\redo.bmp" />
    </Button>
  </ToolBar>
  <ToolBar Band="2" BandIndex="2">
    <Button>
      <Image Source="toolbargraphics\paint.bmp" />
    </Button>
    <Button>
      <Image Source="toolbargraphics\spell.bmp" />
    </Button>
    <Separator/>
    <Button>
      <Image Source="toolbargraphics\save.bmp" />
    </Button>
    <Button>
      <Image Source="toolbargraphics\open.bmp" />
    </Button>
  </ToolBar>
</ToolBarTray>

注解

如果未显式设置此属性,则其值由在其中ToolBar设置该属性的顺序ToolBarTray确定。 例如,如果将两个工具栏放在一个没有设置ToolBarTray和Band属性的BandIndex工具栏中,则这两个工具栏的Band值为 0。 第一个工具栏的 BandIndex 值为 0,第二个工具栏的值为 1。

在 a 中的位置ToolBar取决于属性和ToolBarTray属性的值ToolBarTray.OrientationBand。BandIndex 当设置为Orientation时Horizontal,一个带表示行。ToolBarTray 当为时OrientationVertical,带表示列ToolBarTray。 下表描述了Orientation和 BandBandIndex。

方向 乐队 BandIndex
横向 指示放置位置的 ToolBar 行。 已 Band 设置为较小值的工具栏高于具有较大值的工具栏。 指示在 . 上ToolBar的位置Band。 已 BandIndex 设置为较小值的工具栏位于具有较大值的工具栏左侧。
垂直 指示放置位置的 ToolBar 列。 已 Band 设置为较小值的工具栏位于具有较大值的工具栏左侧。 指示在 . 上ToolBar的位置Band。 已 BandIndex 设置为较小值的工具栏高于具有较大值的工具栏。

Dependency 属性信息

项目 价值
标识符字段 BandIndexProperty
元数据属性设置为 true AffectsParentMeasure

适用于

另请参阅