We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Cannot Update on Selection_Changed Event

I'm trying to update my scheduler with updated data after I have made a scheduler selection.  I am not seeing the changes to the Scheduler view after code execution. 

Here is my code: 

 private void SfScheduler_SelectionChanged(object sender, Syncfusion.Maui.Scheduler.SchedulerSelectionChangedEventArgs e)
    {
        var oldtest = e.OldValue.ToString();


        var newtest = e.NewValue.ToString();


        // Navigation.PushAsync(new SetupPage());


        ControlViewModel cvm = new ControlViewModel();


        cvm.SchedulerEvents = new ObservableCollection<SchedulerAppointment>
            {
                new SchedulerAppointment
                {
                    StartTime = DateTime.Now,
                    EndTime = DateTime.Now.AddHours(2),
                    Subject="Test Subject"
                }
            };
    }

1 Reply 1 reply marked as answer

SS SaiGanesh Sakthivel Syncfusion Team January 23, 2023 11:19 AM UTC

Hi Frederick,


#Regarding Update the events inside the SelectionChanged event

Your requirement can be achieved with the help of SelectionChanged event in the Scheduler. Inside the event, you can reset or update the events as per your requirement. Please refer to the following code snippet for your reference.


Code Snippet

<ContentPage.BindingContext>

    <local:BusinessObjectViewModel x:Name="viewmodel"/>

</ContentPage.BindingContext>

<Grid>

    <scheduler:SfScheduler x:Name="Scheduler"

                        View="Week"

                        AppointmentsSource="{Binding Events}"

                        FirstDayOfWeek="Monday"

                        SelectedCellBackground="Orange"

                        SelectionChanged="Scheduler_SelectionChanged"

                        ShowWeekNumber="True"

                        AllowedViews="Day,Week,WorkWeek,Agenda,Month,TimelineDay,TimelineWeek,TimelineWorkWeek,TimelineMonth">

    </scheduler:SfScheduler>

</Grid>


Inside the SelectionChanged event

void Scheduler_SelectionChanged(System.Object sender, SchedulerSelectionChangedEventArgs e)

{

    viewmodel.Events = new ObservableCollection<SchedulerAppointment>

    {

            new SchedulerAppointment

            {

                StartTime = DateTime.Now,

                EndTime = DateTime.Now.AddHours(2),

                Subject="Test Subject"

            }

    };

}


Please refer to the demo sample in the following locations.

Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/SchedulerMAUI-21975030981


Please let us know if you have any concerns.


Regards,
SaiGanesh Sakthivel


Marked as answer
Loader.
Up arrow icon