A newer version of this page is available. Switch to the current version.

How to: Display the Integrated Ribbon for the Scheduler

  • 4 minutes to read

This example demonstrates how to display the integrated ribbon for the WPF Scheduler and use the ribbon customization actions to add, modify, or remove ribbon elements.

This tutorial consists of the following sections:

Create a New Application

  1. Create a new WPF Application project and open the MainWindow.xaml file in the Visual Studio Designer.
  2. Add the SchedulerControl object to your project. You can do this by dragging the SchedulerControl item from the DX.19.1: Scheduling Toolbox tab to the canvas.

    WPFScheduler_DragDropFromToolbox

  3. Right-click the SchedulerControl object and select Layout | Reset All in the context menu to stretch the SchedulerControl so that it fills the entire window.

Add the Ribbon to the Scheduler

Set the SchedulerControl.CommandBarStyle property to CommandBarStyle.Ribbon to display the integrated ribbon with all the available scheduler commands.

<dxsch:SchedulerControl x:Name="scheduler" CommandBarStyle="Ribbon"/>

The following image shows the resulting application:

WPFScheduler_Examples_StandardRibbonUI

Customize the Ribbon UI

Add the following namespace declarations to the MainWindow.xaml file:

xmlns:dxr="http://schemas.devexpress.com/winfx/2008/xaml/ribbon" 
xmlns:dxb="http://schemas.devexpress.com/winfx/2008/xaml/bars"
xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"

To modify the Scheduler's ribbon UI, add the necessary customization actions to the SchedulerControl.RibbonActions collection. The action's ElementName property specifies the name of the existing ribbon element you wish to change or remove. Element names are the DevExpress.Xpf.Scheduling.DefaultBarItemNames class fields. You can deduce the required element's name by following the naming rules listed in the table below:

Ribbon Element

Element Type

Page Name

Group Name

Item Name

DefaultBarItemNames Field

Page/Tab

WPFScheduler_Examples_RibbonNaming_Tab

Pages

Home

Pages_Home

Group

WPFScheduler_Examples_RibbonNaming_Group

Groups

Home

Appointment

Groups_Home_Appointment

Item

WPFScheduler_Examples_RibbonNaming_Item

Items

Home

Appointment

NewAppointment

Items_Home_Appointment_NewAppointment

Select the action you wish to perform:

  - Remove a Ribbon Element

  - Modify a Ribbon Element

  - Add a New Ribbon Element

  • Remove a Ribbon Element

    To remove an element from the ribbon, add a RemoveAction with the required element's name to the SchedulerControl.RibbonActions collection.

    The following code demonstrates how to remove a specific ribbon group and item:

    TIP

    A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=T544922.

    <dxsch:SchedulerControl.RibbonActions>
                    <!--Remove the Window group from the Home tab.-->
                    <dxb:RemoveAction ElementName="{x:Static Member=dxsch:DefaultBarItemNames.Groups_Home_Window }"/>
                    <!--Remove the Go to Today item on the Home tab, in the Navigate group.-->
                    <dxb:RemoveAction ElementName="{x:Static Member=dxsch:DefaultBarItemNames.Items_Home_Navigate_GotoToday }"/>              
    </dxsch:SchedulerControl.RibbonActions>
    
  • Modify a Ribbon Element

    Use an UpdateAction to change an existing ribbon element. Specify the element's name, the property you wish to modify and the new value that should be assigned to this property.

    The example below demonstrates how to disable the Appointment group on the ribbon and hide the Group by Date button.

    TIP

    A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=T544922.

    <!--Disable the Appointment group on the Home tab.-->
    <dxb:UpdateAction   ElementName="{x:Static dxsch:DefaultBarItemNames.Groups_Home_Appointment }"
                        PropertyName="IsEnabled"
                        Value="False"/>
    <!--Hide the Group by Date item on the Home tab, in the Group By group.-->
    <dxb:UpdateAction   ElementName="{x:Static dxsch:DefaultBarItemNames.Items_Home_GroupBy_GroupByDate }"
                        PropertyName="IsVisible"
                        Value="False"/>
    
  • Add a New Ribbon Element

    To add a new element to the ribbon, add an InsertAction to the SchedulerControl.RibbonActions collection.

    The code below demonstrates how to create a new ribbon button. The About button is located in a separate Example group and uses the BarItem.ItemClick event to display a custom message containing information about the current example.

    TIP

    A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=T544922.

    <!--Add a new group to the Home tab.-->
    <!--The group contains a single button displaying information about this example.-->
    <dxb:InsertAction ContainerName="{x:Static dxsch:DefaultBarItemNames.Pages_Home}" Index="6">
        <dxr:RibbonPageGroup Caption="Example">
            <dxb:BarButtonItem  Content="About"
                                ItemClick="About_ItemClick"
                                LargeGlyph="{dx:DXImageOffice2013 Image=Info_32x32.png}"/>
        </dxr:RibbonPageGroup>
    </dxb:InsertAction>
    

    Handle the About button's BarItem.ItemClick event as shown below.

    Private Sub About_ItemClick(ByVal sender As Object, ByVal e As DevExpress.Xpf.Bars.ItemClickEventArgs)
        DXMessageBox.Show("This example demonstrates how to customize the WPF Scheduler's integrated ribbon UI. Use the Scheduler's RibbonActions collection to create, remove or modify ribbon elements.", "Scheduler Ribbon Example", MessageBoxButton.OK, MessageBoxImage.Information)
    End Sub
    

The complete XAML code for the Scheduler with a custom ribbon is shown below:

Result

Run the application. The following image illustrates the result:

WPFScheduler_Examples_CustomRibbonUI