none
WPF Ribbon的RibbonQuickAccessToolBar如何放置在titlebar里 RRS feed

  • 问题

  • 各位好,我正在尝试使用WPF Ribbon进行开发,但是发现默认生成的工程界面是不包含QuickAccessToolBar的,我想将QuickAccessToolBar放置在窗口标题栏,请问该如何编写xaml?谢谢!

    如下图红框所示

    2012年7月30日 9:14

答案

  • 你好,leehawk_2001

    你只需要手动加上RibbonQuickAccessToolBar就可以了,参考:http://msdn.microsoft.com/zh-cn/library/microsoft.windows.controls.ribbon.ribbonquickaccesstoolbar.aspx

     <ribbon:Ribbon x:Name="Ribbon" Title="Ribbon Title">
                <ribbon:Ribbon.QuickAccessToolBar>
                    <ribbon:RibbonQuickAccessToolBar >
                        <ribbon:RibbonButton x:Name="QATButton1" 
                                             SmallImageSource="brick.png" />
                        <ribbon:RibbonButton x:Name="QATButton2" 
                                             SmallImageSource="brick.png" />
                    </ribbon:RibbonQuickAccessToolBar>
                </ribbon:Ribbon.QuickAccessToolBar>
                <ribbon:Ribbon.ApplicationMenu>
                    <ribbon:RibbonApplicationMenu >
                        <ribbon:RibbonApplicationMenu.AuxiliaryPaneContent>
                            <ribbon:RibbonGallery CanUserFilter="False"
                              ScrollViewer.VerticalScrollBarVisibility="Auto">
                                <ScrollViewer>
                                    <StackPanel>
                                        <ribbon:RibbonButton Content="Button1" Click="RibbonButton_Click_1" Width="100" Height="30"/>
                                        <ribbon:RibbonButton Width="100" Height="30"/>
                                        <ribbon:RibbonButton Width="100" Height="30"/>
                                        <ribbon:RibbonButton Width="100" Height="30"/>
                                        <ribbon:RibbonButton Width="100" Height="30"/>
                                        <ribbon:RibbonButton Width="100" Height="30"/>
                                        <ribbon:RibbonButton Width="100" Height="30"/>
                                        <ribbon:RibbonButton Width="100" Height="30"/>
                                        <ribbon:RibbonButton Width="100" Height="30"/>
                                        <ribbon:RibbonButton Width="100" Height="30"/>
                                        <ribbon:RibbonButton Width="100" Height="30"/>
                                    </StackPanel>
                                </ScrollViewer>
                            </ribbon:RibbonGallery>
                        </ribbon:RibbonApplicationMenu.AuxiliaryPaneContent>
                        <ribbon:RibbonApplicationMenuItem>
                            <ribbon:RibbonButton Content="Open"/>
                        </ribbon:RibbonApplicationMenuItem>
                        <ribbon:RibbonApplicationMenuItem>
                            <ribbon:RibbonButton Content="Open"/>
                        </ribbon:RibbonApplicationMenuItem>
                        <ribbon:RibbonApplicationMenuItem>
                            <ribbon:RibbonButton Content="Open"/>
                        </ribbon:RibbonApplicationMenuItem>
                        <ribbon:RibbonApplicationMenuItem>
                            <ribbon:RibbonButton Content="Open"/>
                        </ribbon:RibbonApplicationMenuItem>
                        <ribbon:RibbonApplicationMenuItem>
                            <ribbon:RibbonButton Content="Open"/>
                        </ribbon:RibbonApplicationMenuItem>
                    </ribbon:RibbonApplicationMenu>
                </ribbon:Ribbon.ApplicationMenu>
            
                <ribbon:RibbonTab Header="Static">
                   
                    <ribbon:RibbonGroup Header="Controls">
                        <ribbon:RibbonButton Label="Button" LargeImageSource="button.jpg" Click="RibbonButton_Click"/>
                        <ribbon:RibbonButton Label="Button" LargeImageSource="button.jpg" Click="RibbonButton_Click"/>
                    </ribbon:RibbonGroup>
                    <ribbon:RibbonGroup Header="Controls">
                        <ribbon:RibbonButton Label="Button" LargeImageSource="button.jpg" Click="RibbonButton_Click"/>
                        <ribbon:RibbonButton Label="Button" LargeImageSource="button.jpg" Click="RibbonButton_Click"/>
                    </ribbon:RibbonGroup>
                </ribbon:RibbonTab>
                <ribbon:RibbonTab Name="DynamicTab" Header="Dynamic" ItemsSource="{Binding}">
                    <ribbon:RibbonTab.ItemContainerStyle>
                        <Style TargetType="ribbon:RibbonGroup">
                            <Setter Property="ItemsSource" Value="{Binding Messages}"/>
                            <Setter Property="ItemTemplate">
                                <Setter.Value>
                                    <DataTemplate>
                                        <ribbon:RibbonButton Label="{Binding Path=Detail}" 
                                                             LargeImageSource="button.jpg" Width="100" Height="100"/>
                                    </DataTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                     
                    </ribbon:RibbonTab.ItemContainerStyle>
                </ribbon:RibbonTab>
            </ribbon:Ribbon>


    Annabella Luo[MSFT]
    MSDN Community Support | Feedback to us

    2012年7月31日 10:52
    版主