Button 元素

代表 按鈕 控制項。

使用方式

<Button
  ApplicationModes = "xs:string"
  CommandName = "xs:positiveInteger or xs:string"
  ApplicationDefaults.IsChecked = "Boolean"/>

屬性

屬性 類型 必要 Description
ApplicationDefaults.IsChecked
Boolean
No
只有當 Button 元素是 QuickAccessToolbar.ApplicationDefaults的子系時,這個屬性才有效。
限制為下列其中一個值:

(true)
預設值。
(false)
ApplicationModes
xs:string
No
只有在 MenuGroup 是父元素時才有效。

(xs:string)
字串,包含介於 0 到 31 之間的逗號分隔整數清單。
空白字元有效且會被忽略。
最大長度:250 個字元。
CommandName
xs:positiveInteger 或 xs:string
No
將專案與 Command產生關聯。

(xs:positiveInteger 或 xs:string)
字串、介於 2 到 59999 之間的整數值、包含或0x2與0xea5f之間的十六進位值,包含。
值在功能區 XML 檔中必須是唯一的。
最大長度:100 個字元。

子元素

沒有子項目。

父元素

元素
ControlGroup
DropDownButton
DropDownGallery
群組
MenuGroup
QuickAccessToolbar.ApplicationDefaults
SplitButton
SplitButton.ButtonItem
SplitButtonGallery

備註

選擇性。

每個 SplitButton.ButtonItem 元素最多可能會發生一次。

每個ControlGroupDropDownButtonDropDownGalleryGroupMenuGroupQuickAccessToolbar.ApplicationDefaultsSplitButton 或 SplitButtonGallery元素可能會發生一或多次。

當按鈕 裝載于應用程式功能表的左欄時,按鈕支援 應用程式模式

範例

下列範例示範 Button的基本標記。

這段程式碼區段會顯示Button Command 宣告,其中包含做為Button元素父容器的相關聯Group

<!-- Button -->
<Command Name="cmdButtonGroup"
         Symbol="cmdButtonGroup"
         Comment="Button Group"
         LabelTitle="ButtonGroup"/>
<Command Name="cmdButton1"
         Symbol="cmdButton1"
         Comment="Button1"
         LabelTitle="Button1"/>
<Command Name="cmdButton2"
         Symbol="cmdButton2"
         Comment="Button2"
         LabelTitle="Button2"/>
<Command Name="cmdButton3"
         Symbol="cmdButton3"
         Comment="Button3"
         LabelTitle="Button3"/>
<Command Name="cmdButtonGroup2"
         Symbol="cmdButtonGroup2"
         Comment="Button Group2"
         LabelTitle="ButtonGroup2"/>
<Command Name="cmdButtonG21"
         Symbol="cmdButtonG21"
         Comment="ButtonG21"
         LabelTitle="ButtonG21">
  <Command.LargeImages>
    <Image Source="res/large.bmp"/>
  </Command.LargeImages>
  <Command.SmallImages>
    <Image Source="res/small.bmp"/>
  </Command.SmallImages>
</Command>
<Command Name="cmdButtonG22"
         Symbol="cmdButtonG22"
         Comment="ButtonG22"
         LabelTitle="ButtonG22">
  <Command.LargeImages>
    <Image Source="res/large.bmp"/>
  </Command.LargeImages>
  <Command.SmallImages>
    <Image Source="res/small.bmp"/>
  </Command.SmallImages>
</Command>
<Command Name="cmdButtonG23"
         Symbol="cmdButtonG23"
         Comment="ButtonG23"
         LabelTitle="ButtonG23">
  <Command.LargeImages>
    <Image Source="res/large.bmp"/>
  </Command.LargeImages>
  <Command.SmallImages>
    <Image Source="res/small.bmp"/>
  </Command.SmallImages>
</Command>
<Command Name="cmdButtonG24"
         Symbol="cmdButtonG24"
         Comment="ButtonG24"
         LabelTitle="ButtonG24">
  <Command.LargeImages>
    <Image Source="res/large.bmp"/>
  </Command.LargeImages>
  <Command.SmallImages>
    <Image Source="res/small.bmp"/>
  </Command.SmallImages>
</Command>

此程式碼區段會顯示 按鈕 控制項宣告。

<Group CommandName="cmdButtonGroup"
       SizeDefinition="ThreeButtons">
  <Button CommandName="cmdButton1"></Button>
  <Button CommandName="cmdButton2"></Button>
  <Button CommandName="cmdButton3"></Button>
</Group>

項目資訊

  • 最低支援系統:Windows 7
  • 可以是空的:是

另請參閱

按鈕控制項

SetModes