private void SfRotator_SelectedIndexChanged(object sender, Syncfusion.SfRotator.XForms.SelectedIndexChangedEventArgs e)
{
var selectedItem = viewModel.ImageCollection[(int)e.Index];
} |
<sfRotator:SfRotator
x:Name="rotator"
SelectedIndexChanged="SfRotator_SelectedIndexChanged" >
<sfRotator:SfRotator.DataSource>
<sfRotator:SfRotatorItem >
<sfRotator:SfRotatorItem.ItemContent>
<local:RotatorTemplateView/>
</sfRotator:SfRotatorItem.ItemContent>
</sfRotator:SfRotatorItem>
< ----------------------------------- >
</sfRotator:SfRotator.DataSource>
</sfRotator:SfRotator> |
private void SfRotator_SelectedIndexChanged(object sender, Syncfusion.SfRotator.XForms.SelectedIndexChangedEventArgs e)
{
var selectedView = rotator.DataSource[(int)e.Index].ItemContent;
}
|
InitializeComponent();
collectionOfItems = new ObservableCollection<SfRotatorItem>();
collectionOfItems.Add(new SfRotatorItem() { ItemContent = new RotatorTemplateView() });
……
collectionOfItems.Add(new SfRotatorItem() { ItemContent = new RotatorTemplateView() });
this.rotator.ItemsSource = collectionOfItems;
|
private void SfRotator_SelectedIndexChanged(object sender, Syncfusion.SfRotator.XForms.SelectedIndexChangedEventArgs e)
{
var item = collectionOfItems[(int)e.Index];
var selectedView = item.ItemContent;
} |
Hi,
The above example can only work with RotatorItem model.
How do we get the current visible item view if we are using ItemTemplate and DataTemplate?
We do not want to use RotatorItem model and use ItemTemplate with Binding.
And get the current visible item view on SelectionIndexChanged event.
How do we achieve that?
Regards,
Haresh
Hi Haresh,
Query: How do we get the currently visible item view if we are using ItemTemplate and DataTemplate?
We have validated your query and when using an ItemTemplate, we can retrieve the SelectedItem value of the view model using the SelectionChanged event. Because the ItemTemplate and ItemsSource combine at run time and we have not stored it in any collections. So it is currently not possible to obtain the visible item view using the ItemTemplate.
Please let us know if you need any other details.
Regards,
Ruba Shanmugam
Hi,
With your solution where we have ItemLayout directly attached with SfRotatorItem completely missing the concept of reusability.
As we are attaching Layout with SFRotatorItem, It will have memory issues if we have 1000+ scrolls, as its missing reusing concepts of native iOS CollectionView and Android recyclerView.
Even default Xamarin Forms does not give a way to know VisibleItems (Contents).
I am still looking for a better way to do it !!!
Hi Haresh,
We regret to inform you that, as we previously stated, the visible item view cannot currently be obtained using the ItemTemplate, only the SelectedItem value of the view model using the SelectionChanged event.
Please let us know if you need any other details.
Regards,
Ruba Shanmugam