Bra*_*rad 4 wpf xaml controls button
如何完成"应用程序"按钮和快速访问工具栏放置? alt text http://i.msdn.microsoft.com/Cc872782.Ribbon01(en-us,MSDN.10).png
首先,在xaml中引用Ribbon命名空间...
<r:RibbonWindow
...
xmlns:r="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary"
>
Run Code Online (Sandbox Code Playgroud)
然后,您可以通过绑定到ViewModel上的RibbonCommand属性来配置应用程序菜单(与绑定其他功能区命令非常相似)
<r:Ribbon>
<r:Ribbon.ApplicationMenu>
<r:RibbonApplicationMenu
Command="{Binding Path=ApplicationMenuCommand}">
<!-- If your first menu item if 'Open File' -->
<r:RibbonApplicationMenuItem
Command="{Binding Path=OpenFileCommand}" />
</r:RibbonApplicationMenu>
</r:Ribbon.ApplicationMenu>
</r:Ribbon>
Run Code Online (Sandbox Code Playgroud)
该属性看起来像这样:
public RibbonCommand OpenFileCommand
{
get
{
if (_openFileCommand == null)
{
_openFileCommand = new RibbonCommand("OpenFileCommand", typeof(RibbonApplicationMenuItem));
_openFileCommand.LabelDescription = "Label Description";
_openFileCommand.LabelTitle = "Label Title";
_openFileCommand.ToolTipDescription = "Tooltip Description";
_openFileCommand.ToolTipTitle = "Tooltip Title";
_openFileCommand.CanExecute += (sender, e) => { e.CanExecute = true; };
_openFileCommand.Executed += (sender, e) => { /* logic to open a file goes here... */; };
}
return _openFileCommand;
}
}
Run Code Online (Sandbox Code Playgroud)
对于你的问题的第二部分 - 我担心我还没有使用QuickAccess工具栏玩过多,但我猜它会从像......这样的东西开始
<r:Ribbon.QuickAccessToolBar>
<r:RibbonQuickAccessToolBar>
<!-- put your RibbonCommands here -->
</r:RibbonQuickAccessToolBar>
</r:Ribbon.QuickAccessToolBar>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6886 次 |
| 最近记录: |