I have list view with about 20 items in it and each item has three radio buttons. It works fine in xamarin forms default list view but SfListView seems to have a bug. If In the UI I tick/untick radio buttons for 4-5 items, than suddenly the radio buttons for some of the items at the bottom of the list gets ticked/unticked. I hope somebody knows what is going on. Just to mention it wokrs fine for 4-5 items in the SfListview
|
<syncfusion:SfListView x:Name="listView" ListViewCachingStrategy="CreateNewTemplate" ItemsSource="{Binding BookInfo}">
<syncfusion:SfListView.ItemTemplate>
<DataTemplate>
<StackLayout Orientation="Horizontal" >
<syncfusion1:SfRadioButton IsChecked="{Binding IsChecked}" CheckedColor="DarkGreen" UncheckedColor="Gray"/>
<Label Text="{Binding BookDescription}" BackgroundColor="White" TextColor="Black"/>
</StackLayout>
</DataTemplate>
</syncfusion:SfListView.ItemTemplate>
</syncfusion:SfListView>
|
Hi Suthi,
Thanks a million for your reply and knowledge share.
As you had mentioned that sflistview recycles the template and it only creates first 10-15 objects and then it just updates the binding values, on top of that when you scroll down the list the hidden radio buttons gets unchecked/checked/unexpected behaviour, which adds more to the current situations.
Anyway along with using a new radioGroupKey for the template/ ensuring for each cached instances (10-15) would have its own unique radio group key, I had to implement some extra checks for binded properties for radio buttons as below:
public bool IsOnline
{
get => _isOnline;
set
{
if (_isOnline != value)
{
if (value || this.isOffline || this.isBusy)
{
isOnLeave = value;
OnPropertyChanged(nameof(User.IsOnline);
}
}
}
}
This issue can occur in both SfListview and xamarin listview.
Hi Suthi,
Thanks for follow up, I will look forward to hear from you.
Yes, it makes perfect sense that the radio button component should be able to handle the scenarios and it is a bug in the xamarin forms component rather than Syncfusion component.
Kind regards,
Bahadur
|
<sfListView:SfListView
x:Name="ctrFieldValue" SelectionBackgroundColor="Transparent"
ItemSpacing="6" SelectionChanged="ctrFieldValue_SelectionChanged"
Loaded="ctrFieldValue_Loaded">
<sfListView:SfListView.ItemTemplate>
<DataTemplate>
<sfButton:SfRadioButton InputTransparent="True"
HorizontalOptions="Start"
IsChecked="{Binding IsChecked, Mode=TwoWay}"
Text="{Binding DisplayName}" />
</DataTemplate>
</sfListView:SfListView.ItemTemplate>
</sfListView:SfListView> |
|
void ctrFieldValue_SelectionChanged(System.Object sender,
Syncfusion.ListView.XForms.ItemSelectionChangedEventArgs e)
{
var itemsSource = ctrFieldValue.ItemsSource as List<CheckBoxField>;
foreach (CheckBoxField item in itemsSource)
{
if (e.AddedItems[0] != item)
{
item.IsChecked = false;
}
else
{
item.IsChecked = true;
}
}
} |
Hi Devakumar,
Much appreciated your help for finding us a solution.
Thanks to the rest of the Syncfusion team too.
Kind regards,
Bahadur