如何在WPF应用程序中自定义功能区控件菜单? [英] How Should I customize Ribbon control Menu in my WPF application?

查看:63
本文介绍了如何在WPF应用程序中自定义功能区控件菜单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<Window x:Class="IndiraLibrary.ApplicationWindow"

    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"

    xmlns:local="clr-namespace:IndiraLibrary"

    Title="Indira Library I-Card System" Height="487" Width="765" WindowState="Maximized" WindowStartupLocation="CenterScreen" Name="MainWindow">
    <Window.CommandBindings>
        <CommandBinding x:Name="NewStudentCommand" Executed="NewStudentCommand_Executed" Command="{x:Static local:ApplicationWindow.CtrlNCommand}"/>
        <CommandBinding x:Name="GenerateCommand" Executed="GenerateCommand_Executed" Command="{x:Static local:ApplicationWindow.CtrlGCommand}"/>
        <CommandBinding x:Name="UpdateCommand" Executed="UpdateCommand_Executed" Command="{x:Static local:ApplicationWindow.CtrlUCommand}"/>
        <CommandBinding x:Name="PrintCommand" Executed="PrintCommand_Executed" Command="{x:Static local:ApplicationWindow.CtrlPCommand}"/>
        <CommandBinding x:Name="ImportCommand" Executed="ImportCommand_Executed" Command="{x:Static local:ApplicationWindow.CtrlICommand}"/>
    </Window.CommandBindings>
    <Grid Name="WindowContent" Height="auto">
            <Grid.RowDefinitions>
                <RowDefinition Height="1" MinHeight="5"></RowDefinition>
                <RowDefinition Height="auto" ></RowDefinition>
                <RowDefinition Height="auto" MinHeight="200"></RowDefinition>
            </Grid.RowDefinitions>
            <Grid Name="ApplicationMenu" VerticalAlignment="Top" Height="auto" Grid.Row="1" removed="Transparent">

                <r:Ribbon Name="Menu" Height="auto" >
                    <r:RibbonTab  Header="Students" Name="Students" FlowDirection="LeftToRight" Width="auto">
                        <r:RibbonGroup Name="New_Student" Header="New Student" Width="auto">
                            <r:RibbonButton Height="auto" Width="auto" KeyTip="n" Name="btnNewStudent" Label="New Student" LargeImageSource="/images/new.png" Click="btnNewStudent_Click" ToolTipDescription="Ctrl+N"  ></r:RibbonButton>
                            <r:RibbonButton Height="auto" Width="auto" Name="btnSave" Label="Save" Command="{Binding Path=StudentDetails.SaveStudentCommand}" LargeImageSource="/images/save.png"></r:RibbonButton>
                        </r:RibbonGroup>                    
                    <r:RibbonGroup Name="UpdateStudents" Header="Update Student Details"  Width="auto">
                            <r:RibbonButton Height="auto" Width="auto" Name="btnUpdateStudents"  Label="Update Students" LargeImageSource="/images/Update.jpg" Click="btnUpdateStudents_Click" ToolTipDescription="Ctrl+U" ></r:RibbonButton>
                        </r:RibbonGroup>
                    </r:RibbonTab>
                <r:RibbonTab  Header="Import Student Details" Name="Import_Student_Details" FlowDirection="LeftToRight" Width="auto">
                    <r:RibbonGroup Name="ImportDetails" Header="Import Student Details" Width="auto">
                        <r:RibbonButton Height="auto" Width="auto" Name="btnImport" LargeImageSource="/images/find.png" Label="Import" Click="btnImport_Click" ToolTipDescription="Ctrl+I" ></r:RibbonButton>
                    </r:RibbonGroup>
                </r:RibbonTab>
                <r:RibbonTab  Header="Print I-Cards" Name="Print_ICards" FlowDirection="LeftToRight" Width="auto">                    
                    <r:RibbonGroup Name="Generate_ICards"  Header="Generate Regular ICards" Width="auto">
                        <r:RibbonButton Height="auto" Width="auto" Name="btnGenerateIcards" LargeImageSource="/images/find.png" Label="Print Regular ICards" Click="btnGenerateIcards_Click" ToolTipDescription="Ctrl+G" ></r:RibbonButton>
                        <r:RibbonButton Height="auto" Width="auto" Name="btnPrint" LargeImageSource="/images/print.png" Label="Print" Click="btnPrint_Click" ToolTipDescription="Ctrl+P" ></r:RibbonButton>
                    </r:RibbonGroup>                   
                </r:RibbonTab>
            </r:Ribbon>
                
            </Grid>
            <Grid Name="ParentWindows" removed="#FFFFFF"  Height="565" Grid.Row="2" VerticalAlignment="Bottom" ScrollViewer.CanContentScroll="True" ScrollViewer.VerticalScrollBarVisibility="Visible"  >
                <Border >
                    <Border.Background>
                        <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                            <GradientStop Color="#A7D7F6" Offset="0" />
                            <GradientStop Color="#FFFFFF" Offset="0.8" />
                        </LinearGradientBrush>
                    </Border.Background>
                </Border>
                <ScrollViewer VerticalScrollBarVisibility="Auto" CanContentScroll="True"  VerticalAlignment="Top" Height="auto" >


                    <Grid Name="ChildWindows" Height="auto" Width="auto" removed="Transparent" >

                    </Grid>
                </ScrollViewer>
            </Grid>
        </Grid>
</Window>

推荐答案

Open the ribbon control in blend and play around with the template.

Start with this[^].
Open the ribbon control in blend and play around with the template.
Start with this[^].


这篇关于如何在WPF应用程序中自定义功能区控件菜单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆