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.
Unfortunately, activation email could not send to your email. Please try again.

How to use EventToCommandBehaviour (from Prism) to get CellTapped event in the ViewModel? (MVVM Pattern)

Thread ID:

Created:

Updated:

Platform:

Replies:

131522 Jul 14,2017 10:11 AM Aug 23,2017 04:45 AM Xamarin.Forms 4
loading
Tags: SfSchedule
Leandro
Asked On July 14, 2017 10:11 AM

Hi, I have implemented an SFSchedule control in my Xamarin.Forms UWP app. But I'm not being able to make the CellTapped event call a command in my ViewModel when i click in some Day Cell with the mouse. You can see that i'm using the MVVM Prism Framework, which has the EventToCommandBehaviour. See my XAML code for the ScheduleControl:

xmlns:syncfusion="clr-namespace:Syncfusion.SfSchedule.XForms;assembly=Syncfusion.SfSchedule.XForms"
xmlns:b="clr-namespace:Prism.Behaviors;assembly=Prism.Forms"

<syncfusion:SfSchedule x:Name="schedule"
                               DataSource="{Binding Meetings}"
                               ScheduleView="MonthView"
                               >
         
            <syncfusion:SfSchedule.Behaviors>
                <b:EventToCommandBehavior Command="{Binding DayClieckedCommand}"
                                    EventName="CellTapped"
                                    EventArgsParameterPath="Item"    
                                    />
            </syncfusion:SfSchedule.Behaviors>
           
</syncfusion:SfSchedule>



And here you can see the Command in my ViewModel

        public DelegateCommand<CellTappedEventArgs> DayClickedCommand => new DelegateCommand<CellTappedEventArgs>(DayClicked);
        public void DayClicked(CellTappedEventArgs args)
        {
            System.Diagnostics.Debug.WriteLine("TEST");
        }

Currently, i'm not being able to even call the method to just print a message for debug purposes. I don't know why the behaviour on the XAML is not calling the Command. Is there another possibility to call commands in the ViewModel, avoiding CodeBehind?

Well, right now im not concerning with parameters, im just trying to call the method, one step at a time. But after, i will need to get in this command the Day that was clicked, to open another page with a Schedule in DayView mode, so i can edit or add appointments in that specific day. I'm kind of lost there because those parameters really blow my mind :)

If anyone can help me please, i'm kind stuck here. Thanks in advance.

Subburaj Pandian Veluchamy [Syncfusion]
Replied On July 19, 2017 10:29 AM

Hi Leandro, 
 
Thank you for contacting Syncfusion support. 
 
Based on the provided information, we have checked and we are unable to reproduce  
the mentioned issue with Schedule CellTapped event is not triggering while tapping with a mouse in Xamarin Forms UWP when triggering the event to Command Behavior. We have prepared sample based on this scenario, please find the below sample. 
 
 
Could you please check the sample and let us know if you face any issue by modifying the provided sample based on your scenario with more details, it will be helpful for us to check on it and provide you the better solution. 
 
Regards,   
Subburaj Pandian V.     


Stephen Hauck
Replied On August 22, 2017 11:16 AM

Paying it forward in case anyone searches for this and is using  Corcav Behaviors  like I am in my MVVM architecture...here is all you need to do






Stephen Hauck
Replied On August 22, 2017 01:15 PM

The above sample will pass in the entire schedule control.

If you just want the CellTappedParameters then simply use this code 



Then in the command cast it like so...




Subburaj Pandian Veluchamy [Syncfusion]
Replied On August 23, 2017 04:45 AM

Hi Stephen, 
 
Thank you for your valuable suggestion. Please let us know if you have any query with SfSchedule, we will happy to help you. 
  
Regards,   
Subburaj Pandian V.  


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;