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
close icon

Alternative solution to DataTemplates required

Hi,

In my project I have a list view that's made up of multiple different data templates for selected items and non selected items. The current implementation is that each unselected data template also has a corresponding selected data template that is an exact duplicate other than the automation ID is different and the background colour changes. This is obviously inefficient and causes significant performance issues but it is currently required for testing purposes.

Is there an alternative solution that you would be able to recommend that would allow for me to continue to use your control as they were intended but without having separate item templates that do nothing but change an automation ID?

Find attached a sample of the XAML currently in my project showing the different data templates and their indentical fields other than automationID and background colour.

Attachment: Sample_f45660d2.zip

5 Replies

GP Gnana Priya Namasivayam Syncfusion Team November 29, 2019 01:55 PM UTC

Hi Liam,                                   

Thank you for contacting Syncfusion support. 

We are currently working on the reported query from our side. We will validate your query and provide you further details on December 2, 2019. We will appreciate your patience until then. 

Regards, 
Gnana Priya N 



LK Liam Keogh replied to Gnana Priya Namasivayam December 2, 2019 03:59 PM UTC

Hi Liam,                                   

Thank you for contacting Syncfusion support. 

We are currently working on the reported query from our side. We will validate your query and provide you further details on December 2, 2019. We will appreciate your patience until then. 

Regards, 
Gnana Priya N 


Hi Gnana, it's now the end of play on the 2nd so I'm wondering if you have a response to my query?


GP Gnana Priya Namasivayam Syncfusion Team December 2, 2019 05:22 PM UTC

Hi Liam, 
 
We suspect that your requirement is to update the AutomationId for the selectedItem on each selection. We have prepared the sample to update the AutomationId on SelectionChanged event like below. We have attached the sample and code snippet for your reference, please find the sample from below. 
 
 
 
private void ListView_SelectionChanged(object sender, Syncfusion.ListView.XForms.ItemSelectionChangedEventArgs e) 
 { 
    for (int i = 0; i < e.AddedItems.Count; i++) 
    { 
       CurrentItem = e.AddedItems[i] as MessageInfo; 
       CurrentItem.AutomationId = 10000;  //You can customize the AutomationId of selected item. 
       if (previousItem != null) 
       { 
          previousItem = e.AddedItems[i] as MessageInfo; 
          prevId = previousItem.AutomationId; 
       } 
         CurrentItem = previousItem; 
   } 
   for (int i = 0; i < e.RemovedItems.Count; i++) 
   { 
         previousItem = e.RemovedItems[i] as MessageInfo; 
   } 
} 
 
 
  
Kindly check with the above sample whether it meets your requirement. If not kindly revert us back with more details in order to understand your query better and provide possible solution at our end. 
 
Regards, 
Gnana Priya N 



LK Liam Keogh December 3, 2019 10:45 AM UTC

Hi Gnana,

I greatly appreciate your time in looking into this issue, however, it does not meet the requirements for what we would be looking for. We actually no longer have a need for this feature so no further work is needed. It seems changing AutomationId of an element actually has a hard restriction on it from Xamarin.Forms itself.

Thank you again.


GP Gnana Priya Namasivayam Syncfusion Team December 4, 2019 06:50 AM UTC

Hi Liam, 
 
Thanks for the update. Please let us know if you have any further query regarding SfListView. 
 
Regards, 
Gnana Priya N 


Loader.
Live Chat Icon For mobile
Up arrow icon