代码之家  ›  专栏  ›  技术社区  ›  Seth Moore

WPF中的带状控件

  •  2
  • Seth Moore  · 技术社区  · 14 年前

    我正在尝试为工具栏创建一些下拉列表,并希望它们看起来像Word中的页面布局下拉列表(如方向和大小菜单)。

    我尝试使用组合框来完成此操作,但我无法确定如何显示选项名,而不是组合框顶部的选定项。是否可以使组合框在顶部显示所需的内容?

    我应该试着用组合框来做这个还是有更好的方法来做这个?

    alt text http://www.mstipsandtricks.com/tips-and-tricks/ms-office-tips-and-tricks/ms-word/How-to-set-orientation-to-entire-document-or-part-of-document-in-MS-Word-2007/figure2.jpg

    编辑: 看起来我需要一个功能区控件。我能用组合框做一个简单的吗?看起来我很接近,我只需要在组合框中显示一个类别而不是所选项目。

    4 回复  |  直到 9 年前
        2
  •  4
  •   David Basarab    14 年前
        3
  •  2
  •   Brian Schroer    14 年前
        4
  •  0
  •   Tinaira    9 年前
    enter image description here

    enter image description here

    <DockPanel>
        <ribbon:Ribbon DockPanel.Dock="Top" Margin="0,-22,0,0">
    
            <Ribbon.ApplicationMenu>
                <RibbonApplicationMenu SmallImageSource="Images/list.png">
    
                    <RibbonApplicationMenu.AuxiliaryPaneContent>
                        <RibbonGallery ScrollViewer.VerticalScrollBarVisibility="Auto">
                            <RibbonGalleryCategory MaxColumnCount="1">
                                <RibbonGalleryItem x:Name="GalleryItem1" Content="C# developer" 
                                    MouseOverBackground="Transparent"
                                    MouseOverBorderBrush="Transparent"
                                    CheckedBackground="Transparent"
                                    CheckedBorderBrush="Transparent"
                                                   />
                                <RibbonGalleryItem>
                                    <Hyperlink x:Name="hl1" Click="hl1_Click">
                                        <Run Text="http://www.bing.com"/>
                                    </Hyperlink>
                                </RibbonGalleryItem>
                            </RibbonGalleryCategory>
                        </RibbonGallery>
                    </RibbonApplicationMenu.AuxiliaryPaneContent>
                    <RibbonApplicationMenuItem x:Name="menuItem1" Header="Add" ImageSource="Images/add.png"/>
                    <RibbonApplicationMenuItem x:Name="menuItem2" Header="Settings"
                                               ImageSource="Images/system_preferences.png"/>
    
                </RibbonApplicationMenu>
            </Ribbon.ApplicationMenu>
            <!--Rider-->
            <RibbonTab x:Name="rbnTab1" Header="Tab1">
                <RibbonGroup x:Name="rbnGr1" Header="General">
                    <RibbonButton x:Name="btnRibbon1" Label="Save" LargeImageSource="Images/filesave.png"/>
                    <RibbonButton x:Name="btnRibbon2" Label="Open" LargeImageSource="Images/load.png"/>
                </RibbonGroup>
                <RibbonGroup x:Name="rbnGr2" Header="New group">
                    <RibbonButton x:Name="btnRibbon3" Label="Font" LargeImageSource="Images/fonts.png"/>
                    <RibbonButton x:Name="btnRibbon4" Label="Delete" LargeImageSource="Images/recycle_bin.png"/>
                </RibbonGroup>
            </RibbonTab>
            <RibbonTab x:Name="rbnTab2" Header="Tab2">
                <RibbonGroup x:Name="rbnGr3" Header="Other Group">
                    <RibbonButton x:Name="btnRibbon5" Label="Play" LargeImageSource="Images/play.png"/>
                    <RibbonButton x:Name="btnRibbon6" Label="List" LargeImageSource="Images/kmenuedit.png"/>
                </RibbonGroup>
                <RibbonGroup x:Name="rbnGr4" Header="What a group">
                    <RibbonButton x:Name="btnRibbon7" Label="Sleep" LargeImageSource="Images/icon_sleep.png"/>
                    <RibbonButton x:Name="btnRibbon8" Label="Add" LargeImageSource="Images/add.png"/>
                </RibbonGroup>
            </RibbonTab>
        </ribbon:Ribbon>
    
        <Grid>
            <Button x:Name="button" Content="Button" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75"/>
    
        </Grid>
    </DockPanel>
    

    <Ribbon.ApplicationMenu> <Ribbon.ApplicationMenu> <RibbonApplicationMenu Visibility="Collapsed"> </RibbonApplicationMenu> </Ribbon.ApplicationMenu>