网站建设泉州,大健康品牌策划公司,阿里云网站备案后,厦门在线制作网站添加带有命令的工具栏 (HTML)03/04/2016本文内容[ 本文适用于编写 Windows 运行时应用的 Windows 8.x 和 Windows Phone 8.x 开发人员。如果你要针对 Windows 10 进行开发#xff0c;请参阅 最新文档 ]ToolBar 是一个简单的控件#xff0c;用于解决命令扩展问题。它具有一个 …添加带有命令的工具栏 (HTML)03/04/2016本文内容[ 本文适用于编写 Windows 运行时应用的 Windows 8.x 和 Windows Phone 8.x 开发人员。如果你要针对 Windows 10 进行开发请参阅 最新文档 ]ToolBar 是一个简单的控件用于解决命令扩展问题。它具有一个 action area其中的命令可以立即使用还具有一个 overflow area其中的命令处于隐藏状态但可以根据最终用户发出的请求进行显示。该控件通过在空间受限时允许命令以动态方式从主要区域移动到辅助区域从而支持自适应行为。 ToolBar 不限于某个应用中的单个位置而可以位于如 Splitview、Flyout 等多个位置中以及 canvas 上。注意 可以在尝试 WinJS 网站上查看以下编码方案的详细信息。创建带有以声明方式添加的命令的工具栏可以以声明方式将命令添加到工具栏。在此方案中工具栏具有四个主要命令和两个辅助命令。WinJS.Namespace.define(Sample, {outputCommand: WinJS.UI.eventHandler(function (ev) {var status document.querySelector(.status);var command ev.currentTarget;if (command.winControl) {var label command.winControl.label || command.winControl.icon || button;var section command.winControl.section || ;var msg section command label was pressed;status.textContent msg;}})});WinJS.UI.processAll();指定命令的分组和退出顺序开发人员可以针对不遵循可见的从右到左顺序的溢出区域指定命令的分组和退出顺序。这可用于屏幕空间受限的情况。控件按从最高值到最低值的顺序退出。默认情况下这些命令按从右到左的顺序退出。但优先级的默认值是未定义的。WinJS.Namespace.define(Sample, {outputCommand: WinJS.UI.eventHandler(function (ev) {var status document.querySelector(.status);var command ev.currentTarget;if (command.winControl) {var label command.winControl.label || command.winControl.icon || button;var section command.winControl.section || ;var priority command.winControl.priority;var msg section command label with priority priority was pressed;status.textContent msg;}})});WinJS.UI.processAll();同时显示多个工具栏开发人员可以创建多个工具栏并同时显示它们。WinJS.Namespace.define(Sample, {outputCommand: WinJS.UI.eventHandler(function (ev) {var status document.querySelector(.status);var command ev.currentTarget;if (command.winControl) {var label command.winControl.label || command.winControl.icon || button;var section command.winControl.section || ;var msg section command label was pressed;status.textContent msg;}})});WinJS.UI.processAll();创建带有使用 WinJS.Binding.List 添加的命令的工具栏WinJS.Binding.List 可用于通过带有命令的工具栏的 data 属性填充该工具栏。data-win-options{data: Sample.commandList}WinJS.Namespace.define(Sample, {commandList: null,outputCommand: WinJS.UI.eventHandler(function (ev) {var status document.querySelector(.status);var command ev.currentTarget;if (command.winControl) {var label command.winControl.label || command.winControl.icon || button;var section command.winControl.section || ;var msg section command label was pressed;status.textContent msg;}})});var dataArray [new WinJS.UI.Command(null,{ id: cmdEdit, label: edit, section: primary, type: button, icon: edit, onclick: Sample.outputCommand }),new WinJS.UI.Command(null,{ id: cmdDelete, label: delete, section: primary, type: button, icon: delete, onclick: Sample.outputCommand }),new WinJS.UI.Command(null,{ id: cmdFavorite, label: favorite, section: primary, type: toggle, icon: favorite,onclick: Sample.outputCommand }),new WinJS.UI.Command(null,{ id: cmdOpenWith, label: open with, section: primary, type: button, icon: openfile,onclick: Sample.outputCommand }),new WinJS.UI.Command(null,{ id: cmdDownload, label: download, section: primary, type: button, icon: download,onclick: Sample.outputCommand }),new WinJS.UI.Command(null,{ id: cmdPin, label: pin, section: primary, type: button, icon: pin, onclick: Sample.outputCommand }),new WinJS.UI.Command(null,{ id: cmdZoom, label: zoom, section: primary, type: button, icon: zoomin, onclick: Sample.outputCommand }),new WinJS.UI.Command(null,{ id: cmdFullscreen, label: full screen, section: primary, type: button, icon: fullscreen,onclick: Sample.outputCommand })];Sample.commandList new WinJS.Binding.List(dataArray);WinJS.UI.processAll();自定义工具栏工具栏的默认颜色由 ui-dark.css 或 ui-light.css 样式表设置具体取决于加载的是哪个样式表。 可以通过重写相应的 CSS 规则来自定义工具栏的颜色。在此示例中将工具栏的背景色设置为透明将工具栏的溢出区域的背景色自定义为与它后面的背景图像相匹配。 /* Add your CSS here */body {background-color: rgb(112,112,112);}#content {text-align: center;overflow: hidden;}.image {position: relative;margin: auto;margin-top: 50px;margin-bottom:50px;}img {max-width: 100%;}.win-toolbar-actionarea {background: transparent;}.win-toolbar-overflowarea {background-color: rgb(74, 61, 78);border: 0;}WinJS.UI.processAll();备注可以在尝试 WinJS 网站上查看以下编码示例和其他编码示例的详细信息。使用代码并立即看到结果。相关主题