Skip to main content

How to: Customize the In-place Editor (legacy)

  • 3 minutes to read

Note

You are viewing documentation for the legacy WPF Scheduler control. If you’re starting a new project, we strongly recommend that you use a new control declared in the DevExpress.Xpf.Scheduling namespace. If you decide to upgrade an existing project in order to switch to the updated scheduler control, see the Migration Guidelines document.

The following example demonstrates how to implement a custom in-place editor instead of a default one.

  1. Create a custom in-place editor using the AppointmentInplaceEditorBase class.

    <dxschui:AppointmentInplaceEditorBase
                x:Class="WpfApplication1.CustomInplaceEditor"
                xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                xmlns:dxschui="http://schemas.devexpress.com/winfx/2008/xaml/scheduler"
                xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
                Height="164" Width="226">
        <Grid>
            <Grid.Resources>
                <Style TargetType="{x:Type TextBlock}">
                    <Setter Property="Foreground" Value="Black"/>
                </Style>
            </Grid.Resources>
            <Border Background="#F3BBD2E8" CornerRadius="5"/>
            <Grid Margin="4">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
    
                <!--Subject-->
                <TextBlock  Grid.Row="0" HorizontalAlignment="Left" Text="Subject: "/>
                <dxe:TextEdit Name="txtSubject" 
                              Margin="0,0,0,4"
                              Grid.Column="1"
                              Text="{Binding Subject}"/>
    
                <!--Label-->
                <TextBlock Grid.Row="1" HorizontalAlignment="Left" Text="Label: "/>
                <dxschui:AppointmentLabelEdit Margin="0,0,0,4" 
                                          Grid.Row="1" Grid.Column="1"
                                          Storage="{Binding Storage}" 
                                          EditValue="{Binding Label}"/>
    
                <!--Description-->
                <TextBlock Grid.Row="2" HorizontalAlignment="Left" Text="Description: "/>
                <dxe:TextEdit Margin="0,0,0,4"
                          Grid.Row="2" Grid.Column="1" 
                          TextWrapping="Wrap" VerticalContentAlignment="Top"
                          Text="{Binding Description}"/>
    
                <!--Buttons-->
                <StackPanel Grid.Row="3" Grid.ColumnSpan="2" 
                        Orientation="Horizontal" HorizontalAlignment="Right">
                    <Button Name="OK_button"
                        Width="60" Margin="0,0,4,0"
                        Content="OK" Click="OK_button_Click" />
                    <Button Name="Cancel_button" 
                        Width="60"
                        Content="Cancel" Click="Cancel_button_Click"/>
                </StackPanel>
            </Grid>
        </Grid>
    </dxschui:AppointmentInplaceEditorBase>
    
  2. Replace a standard in-place editor with a custom one. To do this, handle the SchedulerControl.InplaceEditorShowing event and assign the newly created custom editor to the InplaceEditorEventArgs.InplaceEditor property.

    <dxsch:SchedulerControl Name="schedulerControl1"
                            HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
                            InplaceEditorShowing="schedulerControl1_InplaceEditorShowing">
    </dxsch:SchedulerControl>
    
  3. As a result, when an end-user adds a new appointment by pressing Enter in the selected time cells or edits an existing appointment by clicking it repeatedly, the custom in-place editor will be shown.

    DXScheduler_CustomInplaceEditor