Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>svn!</p> <p>Here is my solution</p> <pre><code>public class CustomRootElement : RootElement { private RadioGroup _defaultGroup = new RadioGroup(0); private Dictionary&lt;string, RadioGroup&gt; _groups = new Dictionary&lt;string, RadioGroup&gt;(); public CustomRootElement(string caption = "") : base(caption , new RadioGroup("default",0)) { } public CustomRootElement(string caption, Group group, Func&lt;RootElement, UIViewController&gt; createOnSelected) : base(caption, group) { var radioGroup = group as RadioGroup; if(radioGroup != null) { _groups.Add(radioGroup.Key.ToLower(), radioGroup); } this.createOnSelected = createOnSelected; } public override UITableViewCell GetCell(UITableView tv) { var cell = base.GetCell(tv); cell.SelectionStyle = UITableViewCellSelectionStyle.None; return cell; } public int Selected(string group) { if (string.IsNullOrEmpty(group)) { throw new ArgumentNullException("group"); } group = group.ToLower(); if (_groups.ContainsKey(group)) { return _groups[group].Selected; } return 0; } public void Select(string group, int selected) { if (string.IsNullOrEmpty(group)) { throw new ArgumentNullException("group"); } var radioGroup = GetGroup(group); radioGroup.Selected = selected; } internal RadioGroup GetGroup(string group) { if (string.IsNullOrEmpty(group)) { throw new ArgumentNullException("group"); } group = group.ToLower(); if (!_groups.ContainsKey(group)) { _groups[group] = new RadioGroup(group , 0); } return _groups[group]; } internal NSIndexPath PathForRadioElement(string group, int index) { foreach (var section in this) { foreach (var e in section.Elements) { var re = e as SlRadioElement; if (re != null &amp;&amp; string.Equals(re.Group, group,StringComparison.InvariantCultureIgnoreCase) &amp;&amp; re.Index == index) { return e.IndexPath; } } } return null; } } public class CustomRadioElement : RadioElement { public event Action&lt;CustomRadioElement&gt; ElementSelected; private readonly static NSString ReuseId = new NSString("CustomRadioElement"); private string _subtitle; public int? Index { get; protected set; } public CustomRadioElement(string caption, string group = null, string subtitle = null) :base(caption, group) { _subtitle = subtitle; } protected override NSString CellKey { get { return ReuseId; } } public override UITableViewCell GetCell(UITableView tv) { EnsureIndex(); var cell = tv.DequeueReusableCell(CellKey); if (cell == null) { cell = new UITableViewCell(UITableViewCellStyle.Subtitle , CellKey); } cell.ApplyStyle(this); cell.TextLabel.Text = Caption; if (!string.IsNullOrEmpty(_subtitle)) { cell.DetailTextLabel.Text = _subtitle; } var selected = false; var slRoot = Parent.Parent as CustomRootElement; if (slRoot != null) { selected = Index == slRoot.Selected(Group); } else { var root = (RootElement)Parent.Parent; selected = Index == root.RadioSelected; } cell.Accessory = selected ? UITableViewCellAccessory.Checkmark : UITableViewCellAccessory.None; return cell; } public override void Selected(DialogViewController dvc, UITableView tableView, NSIndexPath indexPath) { var slRoot = Parent.Parent as CustomRootElement; if (slRoot != null) { var radioGroup = slRoot.GetGroup(Group); if (radioGroup.Selected == Index) { return; } UITableViewCell cell; var selectedIndex = slRoot.PathForRadioElement(Group, radioGroup.Selected); if (selectedIndex != null) { cell = tableView.CellAt(selectedIndex); if (cell != null) { cell.Accessory = UITableViewCellAccessory.None; } } cell = tableView.CellAt(indexPath); if (cell != null) { cell.Accessory = UITableViewCellAccessory.Checkmark; } radioGroup.Selected = Index.Value; var handler = ElementSelected; if (handler != null) { handler(this); } } else { base.Selected(dvc, tableView, indexPath); } } private void EnsureIndex() { if (!Index.HasValue) { var parent = Parent as Section; Index = parent.Elements.IndexOf(this); } } } </code></pre> <p>Hope this help!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload