自定义 Ribbon中的 按钮

来源:互联网 发布:unix和linux的区别 编辑:程序博客网 时间:2024/04/30 12:10

 一 这是整个类型的操作方法

效果:

VS开发:

 

代码:

<?xml version="1.0" encoding="utf-8"?><Elements xmlns="http://schemas.microsoft.com/sharepoint/">  <!--RegistrationId不同数值对应不同对象 http://blog.csdn.net/cdc2011/article/details/8558641 -->  <!--CustomAction 元素介绍 http://msdn.microsoft.com/zh-cn/library/ms460194(v=office.14).aspx -->  <CustomAction    Id="DemoHelloWorldButtun"    RegistrationType="List"    RegistrationId="100"    Location="CommandUI.Ribbon">    <CommandUIExtension>      <CommandUIDefinitions>        <!--Location 为部署按钮模块位置 http://blog.csdn.net/cdc2011/article/details/8558420 -->        <!--第一个按钮-->        <CommandUIDefinition          Location="Ribbon.ListItem.New.Controls._children">          <Button           Id="Ribbon.ListItem.New.Controls.DemoHelloWorldButton"           Alt="Hello World Ribbon Button"           Sequence="2"           Image32by32="_layouts/images/ribbondemo/QQ.jpg"           Command="Demo_HelloWorld"           LabelText="Hello World Demo"           TemplateAlias="o2"/>        </CommandUIDefinition>        <!--第二个按钮-->        <CommandUIDefinition          Location="Ribbon.ListItem.Manage.Controls._children">          <Button           Id="Ribbon.ListItem.Manage.Controls.DemoHelloWorldButton"           Alt="Hello World Ribbon Button"           Sequence="10"            Image16by16="_layouts/images/ribbondemo/QQ.jpg"           Command="Demo_HelloWorld_1"           LabelText="Hello World Demo"           TemplateAlias="o2"/>        </CommandUIDefinition>      </CommandUIDefinitions>      <CommandUIHandlers>        <!--点击按钮可以转接到其他页面或者用JScript跳框-->        <!--第一个按钮点击事件-->        <CommandUIHandler           Command="Demo_HelloWorld"           CommandAction="http://xiaocai:82/Lists/Employees/AllItems.aspx">        </CommandUIHandler>        <!--第二个按钮点击事件-->        <CommandUIHandler           Command="Demo_HelloWorld_1"           CommandAction="javascript:alert('Hello World!');">        </CommandUIHandler>      </CommandUIHandlers>    </CommandUIExtension>  </CustomAction>    <!--删除按钮(先注销 CustomAction 部分,然后添加以下代码[第一个按钮]即可)    <HideCustomAction Id="Ribbon.Documents.New.Controls.DemoHelloWorldButton" Location="Ribbon.Documents.New.Controls._children">  </HideCustomAction>  --></Elements>


 二 针对单独列表定制Ribbon,可以使用 Designer设置比较快。

大概如按照以下步骤来做

 

也可以了解别人的详细做法http://winsystem.ctocio.com.cn/431/11625931_5.shtml


 

原创粉丝点击