Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

How to Properly Reload RadioGroup Programmatically?

$
0
0

I have two RadioGroup(s). The first one is preloaded, the second is initially empty. When the user picks a value from the first RadioGroup, I programmatically load the second one. When I debug I notice that the second RadioGroup contains the elements that I want, but they won't show!

I tried the following, but it throws an exception (on the line where I use the .Reload method) saying "Object reference not set to an instance of an object", but both _locationElement and _locationSection are not null:

            MyRadioElement.OnSelected += delegate(object sender, EventArgs e)
            {
                try
                {
                    string groupName = (sender as MyRadioElement).Group;
                    if (groupName == _ownerGroupName)
                    {
                        //user just selected a different owner.
                        //enable and load locations here
                        int ownerID = (int)(sender as MyRadioElement).ElementValue;
                        
                        CreateLocationElement(ownerID);

                        //here _locationElement contains 6 items but they don't show!
                        _locationElement.Reload(_locationSection, UITableViewRowAnimation.Fade);
                    }
                }
                catch (Exception ex)
                {
                    new UIAlertView("Exception", ex.Message, null, "OK", null).Show();
                }
            };

Where CreateLocationElement adds the radio elements:

_locationSection = new Section("Select a Location");
_locationSection.AddAll(_locationElements); //the list of my N items

_locationElement = new RootElement("Location", new RadioGroup("locations", 0) {
    _locationSection
};

Basically I don't know how to use the Reload method properly...Thanks!


Viewing all articles
Browse latest Browse all 204402

Trending Articles



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