Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WPF > Scheduler > Extract text from CustomAppointmentTemplate

Not answered Extract text from CustomAppointmentTemplate

Feed from this thread
  • Maarten avatar

    Posted on Aug 12, 2011 (permalink)

    Hello Telerik Team,

    I got my Custom template made for my EditAppointmentDialog:

    <Window.Resources>
            <Style TargetType="telerik:AppointmentDialogWindow" x:Key="AppointmentDialogWindowStyle">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="telerik:AppointmentDialogWindow">
                            <StackPanel DataContext="{TemplateBinding EditedAppointment}" Width="150" Height="150">
                                <Label x:Name="lblContact">
                                    <Label.Content>
                                        <Grid ShowGridLines="True">
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="50"/>
                                                <ColumnDefinition Width="150"/>
                                            </Grid.ColumnDefinitions>
                                            <Grid.RowDefinitions>
                                                <RowDefinition Height="50"/>
                                                <RowDefinition Height="50"/>
                                                <RowDefinition Height="50"/>
                                            </Grid.RowDefinitions>
     
                                            <Label Content="Subject: " Grid.Column="0" Grid.Row="0" />
                                            <TextBox x:Name="SubjectBox" Grid.Column="1" Grid.Row="0" Width="125" Height="30" Text="{Binding Subject}"/>
     
                                            <Label Content="Body: " Grid.Column="0" Grid.Row="1" />
                                            <TextBox x:Name="BodyBox" Grid.Column="1" Grid.Row="1" Width="125" Height="30" Text="{Binding Body}" />
     
                                            <Button x:Name="saveBtn" Command="telerik:RadSchedulerCommands.SaveAppointment"  Content="Save"  TabIndex="7" Focusable="True" Width="55" Height="20" ToolTip="save appointment and close dialog" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Row="2" Grid.ColumnSpan="2"/>
                                        </Grid>
                                    </Label.Content>
                                </Label>
                            </StackPanel>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </Window.Resources>

    My question now is, how do I get the text from those textboxes?
    I want to send them in plain text to a database.

    How my code is enough.

    Thanks in advance!
    Maarten

    Reply

  • Maarten avatar

    Posted on Aug 13, 2011 (permalink)

    Ok sorry for that previous message, I found that already.

    Next question:
    <Button x:Name="saveBtn" Command="telerik:RadSchedulerCommands.SaveAppointment" Content="Save"  TabIndex="7" Focusable="True" Width="55" Height="20" ToolTip="save appointment and close dialog" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Row="4" Grid.ColumnSpan="2"/>

    This command gets the SaveAppointment, but what do I have to do when I want to Edit an appointment? Because everytime I Click this button, it will save the appointment instead of edit the appointment.

    Next question: When I want to delete an appointment and I press the little cross. I want to access the data in that appointment without the need of the scheduler.SelectedAppointment.Subject for example. Without this line I cannot delete an appointment without getting an error.

    How can I fix this?

    Thanks in advance!
    Maarten

    Reply

  • Pana Pana admin's avatar

    Posted on Aug 19, 2011 (permalink)

    Hi,

    You could use the telerik:RadSchedulerCommands.EditAppointment command and add handler for the AppointmentDeleted event. The event handler args have property Appointment that have the deleted appointment. For example:
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Button Grid.Row="0" Content="Edit" Command="telerik:RadSchedulerCommands.EditAppointment" CommandTarget="{Binding ElementName=schedule}" CommandParameter="{Binding ElementName=schedule, Path=SelectedAppointment}" />
        <telerik:RadScheduler x:Name="schedule" Grid.Row="1" AppointmentDeleted="RadScheduler_AppointmentDeleted" />
    </Grid>

    With the following codebehind:
    private void RadScheduler_AppointmentDeleted(object sender, AppointmentDeletedEventArgs e)
    {
        RadWindow.Alert(e.Appointment);
    }


    RadScheduler is still there but we would like to encourage our clients to migrate to RadScheduleView. It supports better MVVM, has better virtualization and overall performance. Your requests can be done easily. Using the RadScheduleView. If you used RadScheduleView you could add handler for AppointmentDeleted event and the event args would have Appointment parameter. As for the edit instead of save the RadScheduleView has EditAppointment command. The code would look like:

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Button Grid.Row="0" Content="Edit" Command="telerik:RadScheduleViewCommands.EditAppointment" CommandTarget="{Binding ElementName=schedule}" CommandParameter="{Binding ElementName=schedule, Path=SelectedAppointment}" />
        <telerik:RadScheduleView x:Name="schedule" Grid.Row="1" AppointmentDeleted="RadScheduleView_AppointmentDeleted">
            <telerik:RadScheduleView.AppointmentsSource>
                <telerik:ObservableAppointmentCollection />
            </telerik:RadScheduleView.AppointmentsSource>
            <telerik:RadScheduleView.ViewDefinitions>
                <telerik:DayViewDefinition />
                <telerik:WeekViewDefinition />
                <telerik:MonthViewDefinition />
                <telerik:TimelineViewDefinition />
            </telerik:RadScheduleView.ViewDefinitions>
        </telerik:RadScheduleView>
    </Grid>

    And in code behind you could get the deleted appointment:
    private void RadScheduleView_AppointmentDeleted(object sender, Telerik.Windows.Controls.AppointmentDeletedEventArgs e)
    {
        RadWindow.Alert(e.Appointment);
    }


    Regards,
    Pana
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WPF > Scheduler > Extract text from CustomAppointmentTemplate
Related resources for "Extract text from CustomAppointmentTemplate"

WPF Scheduler Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  ]