So I have this list I need to select items from, and I'm not able to get the selection feature to work, this is my code:
<syncfusion2:SfListView SelectionMode="Multiple"
SelectionGesture="Tap"
x:Name="bandSch"
SelectionBackgroundColor="#e8e8e8"
AbsoluteLayout.LayoutBounds="0,0.8,1,0.3"
AbsoluteLayout.LayoutFlags="All"
ItemSize="40"
ItemsSource="{Binding Source={local2:BandInfoRepository}, Path=BandInfo}">
<syncfusion2:SfListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Padding="5,0,5,5" Orientation="Horizontal">
<Label Text="{Binding BandSchedule}"
TextColor="#00b5d1"
FontSize="12"
FontAttributes="Bold"
HorizontalOptions="FillAndExpand"
HorizontalTextAlignment="Center"
VerticalOptions="FillAndExpand"
VerticalTextAlignment="Center"
WidthRequest="50"
/>
<Button Text="Seleccionar"
FontSize="16"
TextColor="#00b5d1"
BackgroundColor="#e8e8e8"
Margin="5"
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand"
BorderRadius="14"
/>
</StackLayout>
</ViewCell>
</DataTemplate>
</syncfusion2:SfListView.ItemTemplate>
</syncfusion2:SfListView>
I'd love a little help with this, as I cannot get either single or multiple selection to work and I have no idea why.
After struggling with this myself I discovered that it could be a combination of issues that would cause this. In my scenario I had the code initialized within my iOS AppDelegate.cs file, but I had set a background color for the item in a data template. It appears that if you set a background color on the item, then the selection action will not change the background. This causes it to appear as if the selection is not operating correctly, when in fact it's just the background color isn't being changed on selection. In my case I removed the item background and let the selection background change the background color at the time of selection. This fixed my issues.
On the initialization of the renderer in the AppDelegate.cs I would like to mention that auto complete within Visual Studio 2017 Community Edition didn't help me much in finding the path to the import I needed to allow me to call the renderer's init function. After about 30 minutes of frustration I found it in the following package. Hope this saves someone else some time in the future.
Using statement at the top:
using Syncfusion.ListView.XForms.iOS;
What my FinishedLaunching looks like.
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
global::Xamarin.Forms.Forms.Init();
// Call the INIT.
SfListViewRenderer.Init();
mainForms = new App();
LoadApplication(mainForms);
return base.FinishedLaunching(app, options);
}