Scheduler AgendaItemTemplate Button Fire Button

Hi,

I have a Scheduler AgendaItemTemplate Button. I would like to Fire button with CommandParameter using Xamarin Forms MVVM.


Thank you.


1 Reply

SS SaiGanesh Sakthivel Syncfusion Team October 25, 2021 12:10 PM UTC

Hi Muthu,

Thank you for using Syncfusion products.

#Regarding SfSchedule appointment Button Fire event in MVVM
We have checked the reported scenario from our end. Your requirement can be achieved with help of EventToCommandBehavior. Please refer to the following code snippet for your reference.

Code Snippet

In the view model class
private Command onMonthInlineAppointmentLoadedCommand;

public Command OnMonthInlineAppointmentLoadedCommand
{
get { return onMonthInlineAppointmentLoadedCommand; }
set
{
onMonthInlineAppointmentLoadedCommand = value;
this.OnPropertyChanged("OnMonthInlineAppointmentLoadedCommand");
}
}

public SchedulerViewModel ()
{
OnMonthInlineAppointmentLoadedCommand = new Command(OnMonthInlineAppointmentLoaded);
}

private void OnMonthInlineAppointmentLoaded(MonthInlineAppointmentLoadedEventArgs obj)
{
var appointment = (obj.appointment as Meeting);
Button button = new Button();
button.Text = appointment.EventName;
button.BackgroundColor = appointment.Color;
button.TextColor = Color.White;
button.Clicked += Button_Clicked;
obj.view = button;
}

private void Button_Clicked(object sender, EventArgs e)
{
App.Current.MainPage.DisplayAlert("", (sender as Button).Text.ToString(), "OK");
}

Please refer to the sample in the following locations.

Please let us know if you have any concerns.

Regards,
SaiGanesh Sakthivel



Loader.
Up arrow icon