wpf 色带样品

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1095163/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 20:41:27  来源:igfitidea点击:

Ribbon sample

wpfoffice-2007ribbon

提问by tom7

I am using the WPF ribbon CTP from Microsoft. However, there is no sample. I am not sure where to start. The RibbonWindow does not have a property for the Ribbon. Does anyone have a sample that works?

我正在使用 Microsoft 的 WPF 功能区 CTP。但是,没有样本。我不知道从哪里开始。RibbonWindow 没有 Ribbon 的属性。有没有人有一个有效的样本?

回答by Nattrass

If you're using the WPF Ribbon http://msdn.microsoft.com/en-us/library/ff799534(v=vs.100).aspx

如果您使用的是 WPF 功能区 http://msdn.microsoft.com/en-us/library/ff799534(v=vs.100).aspx

The MSDN documentation has good examples on how to use each component.

MSDN 文档有关于如何使用每个组件的很好的例子。

http://msdn.microsoft.com/en-us/library/microsoft.windows.controls.ribbon(v=vs.100).aspx

http://msdn.microsoft.com/en-us/library/microsoft.windows.controls.ribbon(v=vs.100).aspx

<r:RibbonWindow
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:r="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary"
        x:Class="MainWindowView"
        Title="MainWindowView" Height="300" Width="515">
    <DockPanel>
        <r:Ribbon DockPanel.Dock="Top">
        <r:RibbonTab x:Name="tab1" Header="Tab1">
            <r:RibbonGroup Header="Group1">
                <r:RibbonButton x:Name="button1" Label="Button 1" LargeImageSource="/Images/button1.png" />
                <r:RibbonButton x:Name="button2" Label="Button 2" LargeImageSource="/Images/button2.png"/>
                <r:RibbonButton x:Name="button3" Label="Button 3" LargeImageSource="/Images/Button3.png"/>
            </r:RibbonGroup>
            <r:RibbonGroup Header="Group2">
                <r:RibbonButton x:Name="button4" Label="Button 4" LargeImageSource="/Images/button4.png"/>
            </r:RibbonGroup>
            <r:RibbonGroup Header="Group 3">
                <r:RibbonMenuButton Label="Button 5" LargeImageSource="/Images/button5.png" >
                    <r:RibbonButton x:Name="button6" Label="Button 6" SmallImageSource="/Images/button6.png"/>
                </r:RibbonMenuButton>
                <r:RibbonMenuButton Label="Button 7" LargeImageSource="/Images/button7.png" >
                    <r:RibbonButton x:Name="button8" Label="Button 8" />
                </r:RibbonMenuButton>
            </r:RibbonGroup>
        </r:RibbonTab>
    </r:Ribbon>
    </DockPanel>
</r:RibbonWindow>

The only gotcha is that you need to update your view to inherit from RibbonWindow instead of Window.

唯一的问题是您需要更新视图以从 RibbonWindow 而不是 Window 继承。