Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 89864

RadioButton in a ListView Problem

$
0
0

I am running into a bit of an issue when implementing the new experimental RadioButton in a ListView. The radio buttons work great until I start scrolling though the list. After selecting a few options for each radio group in the beginning of the list, then scrolling to the bottom, they become non responsive, and seem to have the same values selected as the one at the top of the list. It's almost like it's sharing/conflicting with other radio button elements in the list.

I have added some quick and dirty code below to demonstrate the issue.

public class MainPage : ContentPage
    {
        public MainPage()
        {
            int numberOfRows = 10;
            List<object> objList = new List<object>();
            for (int i = 0; i < numberOfRows; i++) { objList.Add(new object()); }

            Content = new ListView()
            {
                RowHeight = 155,
                ItemsSource = objList,
                ItemTemplate = new DataTemplate(typeof(RadioCell))
            };
        }
    }

    public class RadioCell : ViewCell
    {
        public RadioCell()
        {
            //New Group Name
            string group = Guid.NewGuid().ToString();
            View = new StackLayout
            {
                Spacing = 0,
                Padding = 5,
                Children = {
                    new Label { Text = "Options?"},
                    new RadioButton { Text = "OPTION 1", GroupName = group },
                    new RadioButton { Text = "OPTION 2", GroupName = group },
                    new RadioButton { Text = "OPTION 3", GroupName = group }
                }
            };
        }
    }

Viewing all articles
Browse latest Browse all 89864

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>