RadScheduleView - NavigationHeader new button

1 Answer 41 Views
ScheduleView
Ohad
Top achievements
Rank 3
Bronze
Iron
Iron
Ohad asked on 29 May 2022, 01:15 PM

How can I add my own button as I marked in the picture?

            <telerik:RadScheduleView.ViewDefinitions>
                <telerik:DayViewDefinition DayStartTime="8:00" DayEndTime="20:00"/>
                <telerik:WeekViewDefinition DayStartTime="8:00" DayEndTime="20:00" x:Name="WeekViewDefinition"/>
                <telerik:MonthViewDefinition />
            </telerik:RadScheduleView.ViewDefinitions>

1 Answer, 1 is accepted

Sort by
1
Accepted
Stenly
Telerik team
answered on 30 May 2022, 03:22 PM

Hello Ohad,

One way of achieving this result would be to subscribe to the Loaded event of the RadScheduleView control. In it, get the Grid layout with x:Name="ScheduleViewHeader" and add a new ColumnDefinition instance to its ColumnDefinitions collection. Then, set its second child element (StackPanel which contains additional navigation buttons and current view definition information) to the last column definition through the Grid.SetColumn method. Finally, create a new RadButton control, set it to the second column definition, and add it to the Children collection of the Grid layout.

The following code snippet shows a sample implementation of this approach:

private void RadScheduleView_Loaded(object sender, RoutedEventArgs e)
{
    var scheduleView = (RadScheduleView)sender;

    var gridLayout = scheduleView.ChildrenOfType<Grid>().FirstOrDefault(x => x.Name == "ScheduleViewHeader");

    if (gridLayout != null)
    {
        var columnDefinition = new ColumnDefinition();
        gridLayout.ColumnDefinitions.Add(columnDefinition);

        var secondChild = gridLayout.Children[1];
        Grid.SetColumn(secondChild, 2);

        var button = new RadButton() 
        { 
            Content = "My Custom Button",
            HorizontalAlignment = HorizontalAlignment.Left,
            VerticalAlignment= VerticalAlignment.Center,
            Margin = new Thickness(0, 5, 0, 5) 
        };

        Grid.SetColumn(button, 1);
        gridLayout.Children.Add(button);
    }
}

The produced result is as follows:

I have also attached a sample project, which has this suggestion implemented.

Regards,
Stenly
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Ohad
Top achievements
Rank 3
Bronze
Iron
Iron
commented on 31 May 2022, 06:20 AM

Helped me a lot, thank you very much!
Tags
ScheduleView
Asked by
Ohad
Top achievements
Rank 3
Bronze
Iron
Iron
Answers by
Stenly
Telerik team
Share this question
or