Hi Dev,
Greetings from Syncfusion.
Query1: Get an error"LoadTemplate cannot be null" when using a data template selector.
We have validated your query and currently, we don't have support for having a separate template for each item in SfRotator. We have already considered this to be a feature request and it will be available on our upcoming volume 2 main release 2019. Which will be available on end of June 2019. We appreciate your patience until then.
Query 2: How to use control with views
We have created a sample to achieve your requirement with views inside the SfRotator control. Please find the sample from below link.
In this sample, we have done the following things
1. Added the DataTemplate with views as like below code snippet
<ContentPage.Resources> <ResourceDictionary> <DataTemplate x:Key="RotatorTemplate"> <StackLayout Orientation="Vertical" HorizontalOptions="Center"> <Label Text="{Binding Name}" TextColor="Black" WidthRequest="150" VerticalTextAlignment="Center" /> <ContentPresenter Content="{Binding ItemTemplate}" /> </StackLayout> </DataTemplate> </ResourceDictionary> </ContentPage.Resources> <ContentPage.Content> <sf:SfRotator x:Name="rotator" ItemsSource="{Binding RotatorCollection,Mode=TwoWay }" ItemTemplate="{StaticResource RotatorTemplate}" NavigationDirection="Horizontal" NavigationStripMode="Dots" EnableSwiping="True" EnableLooping="False" VerticalOptions="CenterAndExpand" NavigationStripPosition="Bottom"> </sf:SfRotator> </ContentPage.Content> |
2. Created the view model with Item template as like below code snippet and set the binding context to the rotator.
public class RotatorModel {
public RotatorModel(string name, View itemTemplate) { Name = name; ItemTemplate = itemTemplate; } private String name; public String Name { get { return name; } set { name = value; } } private View itemTemplate; public View ItemTemplate { get { return itemTemplate; }
set { itemTemplate = value; } } } |
Query 2: On a physical device the click event does not work
We have tried to replicate the reported "SfRotator with button in data template does not fire click event" issue at our end by created a sample based on provided code snippet. Since we are not aware of your exact application scenario, so we request you to try our sample and can you please revert us by modifying the sample based on your application along with replication procedure.
This will be helpful for us to investigate further and provide you a better solution at the earliest.
Please find the sample & video from below link
Note: We have checked with following devices, Moto E2(API 23), Moto G4(API 24), Samsung SM-G50F (API 26). Please let us device configuration for provide a better solution.
Please get back us, if you have any concern.
Regards,
Muneesh Kumar G