MonthChangedCommand gets fired multiple times

Hello,

I found that when the SfCalendar control is placed in the Header of a CollectionView, the MonthChangedCommand command fires multiple times when swiping months back and forth. 


I was able to reproduce it on Android (didn't try iOS). Please see the attached repro project. Run it on an android device and start swiping to the previous month and back to the current. Keep watching what is happening in the Debug output.


Also another related question - why the MonthChangedCommand is called on a NON-UI thread? Is it a bug or expected behaviour?


Thank you! 


Kind regards,

Valeriy


Attachment: CalendarXamarin_AndroidBug_ae2e2ff5.zip

11 Replies

SS SaiGanesh Sakthivel Syncfusion Team January 24, 2022 01:56 PM UTC

Hi Valeriy, 
 
#Regarding MonthChangedCommand trigger for multiple time when set the SfCalendar inside the Collectionview Header. 
Currently, we are validating the reported scenario from our end. we will update the further details on the January 26, 2022. We appreciate your patience until then. 
 
Regards,
SaiGanesh Sakthivel
 



MS Muniappan Subramanian Syncfusion Team January 26, 2022 09:31 AM UTC

Hi Valeriy, 
 
We have checked your requirement “MonthChangedCommand gets fired multiple times”. We suspect that it is a sample level issue, now it is working fine. We have prepared a sample for the same, please find the sample by the following link.  
 
Code Snippet: 
void HandleMonthChanged(MonthChangedEventArgs e) 
{ 
    Debug.WriteLine("SELECTED MONTH CHANGED " + e.PreviousValue + " " + e.CurrentValue); 
} 
 
public ViewModel() 
{ 
    this.Appointments = new CalendarEventCollection(); 
    this.AddAppointmentDetails(); 
    this.AddAppointments(); 
    SetItems(); 
} 
 
 
We hope this helps. Kindly revert us if you have any concern. 
 
Regards, 
Muniappan S. 



VK Valeriy Kovalenko January 31, 2022 01:33 PM UTC

Hi Muniappan,

Thanks for getting back to me! Well, that doesn't really help me because in my case items in the CollectionView have to be updated based on the currently selected month. So `SetItems()` has to be called each time as it was in my example.

If I put it back into the HandleMonthChanged method, I see the issue with multiple calls. 


Is there anything I can do to work around this?


Kind regards,

Valeriy



SS SaiGanesh Sakthivel Syncfusion Team February 1, 2022 01:40 PM UTC

Hi Valeriy,  
  
#Regarding MonthChangedCommand trigger for multiple time when set the SfCalendar inside the Collectionview Header.  
Currently, we are validating the reported scenario from our end. we will update the further details on the February 3, 2022. We appreciate your patience until then.  
  
Regards,
SaiGanesh Sakthivel
  



SS SaiGanesh Sakthivel Syncfusion Team February 3, 2022 02:17 PM UTC

Hi Valeriy, 
 
#Regarding MonthChangedCommand trigger for multiple time when set the SfCalendar inside the Collectionview Header 
We have suspect that the issue is in the Xamarin Framework. Currently, we are analyzing the reported scenario from our source level. We will update you on the further details on February 7, 2022. We appreciate the patience until then. 
 
Regards,
SaiGanesh Sakthivel
 



VK Valeriy Kovalenko February 3, 2022 02:21 PM UTC

Hi SaiGanesh,

Thank you for keeping me posted! 


Kind regards,

Valeriy



SS SaiGanesh Sakthivel Syncfusion Team February 4, 2022 02:01 PM UTC

Hi Valeriy, 
 
As we have mentioned in previous update. We will update the further details on February 7,2022. We appreciate your patience until then.  
  
Regards,  
SaiGanesh Sakthivel 



SS SaiGanesh Sakthivel Syncfusion Team February 7, 2022 01:34 PM UTC

Hi Valerity, 
 
#Regarding MonthChangedCommand trigger for twice when set the SfCalendar inside the Collectionview Header
The reported scenario is the Xamarin form framework issue for the Android platform. The reported issue occurs due to the OnElementChanged method in the source level being called when clearing the itemsource of CollectionView and adding the new collection to the itemsource. It triggers the OnElementChanged method for the calendar, which is placed inside the CollectionView Header. So, we suggest you place the calendar inside the grid layout instead of the collection view header and place the collection view below the calendar inside the grid. Please refer to the demo sample in the following location for your reference. 
 
 
Please let us know if you have any concerns. 
 
Regards,
SaiGanesh Sakthivel
 



VK Valeriy Kovalenko February 7, 2022 01:50 PM UTC

Hi SaiGanesh, 

Thanks for getting back to me. Yes, I was considering this workaround, but in this case on smaller screens there are too little space left (since the calendar doesn't scroll away and always stays on top) and UX is not great (considering a long list of elements in the collection view).


I wonder if you may suggest any directions where to look for a fix/workaround to make it work within the header view?


Kind regards,

Valeriy





VK Valeriy Kovalenko replied to SaiGanesh Sakthivel February 7, 2022 02:28 PM UTC

Hi SaiGanesh,

Your explanation helped me to find a workaround - if I don't use Clear() or ReplaceRange(..) but delete items one buy one, there is no multiple calls. I'm going to stick with this workaround unless you can suggest any better way to handle this.


Kind regards,

Valeriy



SS SaiGanesh Sakthivel Syncfusion Team February 8, 2022 01:57 PM UTC

Hi Valeriy, 
 
We are glad to know that you have found a workaround for the reported scenario. As we mentioned in the previous update, the reported scenario is a framework issue. So, we have given an alternative workaround. Please let us know if you need further assistance on this. 
 
Regards,
SaiGanesh Sakthivel


Loader.
Up arrow icon