Appointments location in RadScheduleView

2 posts, 0 answers
  1. Alexandre
    Alexandre avatar
    1 posts
    Member since:
    Jul 2014

    Posted 08 Jul 2014 Link to this post

    Hello

    I need to add appointments in a few locationRessources with code behind. I can build and run my project but the appointments don't appear in the RadScheduleView.

    Here is my xaml code:
    <Window x:Class="TelerikWpfApp1.MainWindow"
                    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
                    Title="MainWindow" Height="350" Width="525">
            <Grid>
                <telerik:RadScheduleView HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Name="xRadScheduleView">
                    <telerik:RadScheduleView.ViewDefinitions>
                        <telerik:DayViewDefinition Orientation="Horizontal" DayStartTime="7:00" DayEndTime="21:00"/>
                        <telerik:WeekViewDefinition/>
                        <telerik:MonthViewDefinition/>
                        <telerik:TimelineViewDefinition/>
                    </telerik:RadScheduleView.ViewDefinitions>
                
            </telerik:RadScheduleView>
     
        </Grid>
    </Window>

    Here is my code behind:
    void MainWindow_Loaded(object sender, RoutedEventArgs e)
            {
                ResourceType locationResource = new ResourceType("BlocsOperatoires");
                locationResource.Resources.Add(new Resource("Bloc 1"));
                locationResource.Resources.Add(new Resource("Bloc 2"));
                locationResource.Resources.Add(new Resource("Bloc 3"));
                locationResource.Resources.Add(new Resource("Bloc 4"));
                locationResource.Resources.Add(new Resource("Bloc 5"));
                this.xRadScheduleView.ResourceTypesSource = new ResourceTypeCollection
                {
                    locationResource
                };
     
                GroupDescriptionCollection groupDescription = new GroupDescriptionCollection
                {
                    new DateGroupDescription(),
                    new ResourceGroupDescription{ ResourceType = "BlocsOperatoires" }               
                };
                this.xRadScheduleView.GroupDescriptionsSource = groupDescription;
     
                var appointments = new ObservableCollection<Appointment>();
                appointments.Add(new Appointment()
                            {
                                Subject = "I'm a new Appointment",
                                Start = new DateTime(2014, 7, 8, 8, 30, 00),
                                End = new DateTime(2014, 7, 8, 10, 30, 00),
                                Location = locationResource.Resources.ElementAt(1).ResourceName
                            });
                appointments.Add(new Appointment()
                {
                    Subject = "I'm a new Appointment 2",
                    Start = new DateTime(2014, 7, 8, 8, 30, 00),
                    End = new DateTime(2014, 7, 8, 10, 30, 00),
                    Location = locationResource.Resources.ElementAt(3).ResourceName
                });
                xRadScheduleView.AppointmentsSource = appointments; 
            }


    Can you explain to me what am i missing ?

    thanx !
  2. Kalin
    Admin
    Kalin avatar
    1209 posts

    Posted 11 Jul 2014 Link to this post

    Hi Alexandre,

    You would need to add the desired resources to the Resources property of the Appointment in order to get it working correctly. I have modified the provided code snippet in order to demonstrate the exact approach:

    var appointments = new ObservableCollection<Appointment>();
     
    var app1 = new Appointment()
    {
        Subject = "I'm a new Appointment",
        Start = new DateTime(2014, 7, 8, 8, 30, 00),
        End = new DateTime(2014, 7, 8, 10, 30, 00),
    };
     
    app1.Resources.Add(locationResource.Resources.ElementAt(1));
    appointments.Add(app1);
     
    var app2 = new Appointment()
    {
        Subject = "I'm a new Appointment 2",
        Start = new DateTime(2014, 7, 8, 8, 30, 00),
        End = new DateTime(2014, 7, 8, 10, 30, 00),
    };
    app2.Resources.Add(locationResource.Resources.ElementAt(3));
    appointments.Add(app2);
     
    xRadScheduleView.AppointmentsSource = appointments;

    For more details about the ScheduleView Resources, please check the following article from our online help documentation:
    http://www.telerik.com/help/wpf/radscheduleview-features-resources.html

    Hope this helps.

    Regards,
    Kalin
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top