static void OnIsCheckedChanged(BindableObject bindable, object oldValue, object newValue) { RadioBehavior behavior = (RadioBehavior)bindable; if ((bool)newValue) { string groupName = behavior.GroupName; List <RadioBehavior> behaviors = null; if (String.IsNullOrEmpty(groupName)) { behaviors = defaultGroup; } else { behaviors = radioGroups[groupName]; } foreach (RadioBehavior otherBehavior in behaviors) { if (otherBehavior != behavior) { otherBehavior.IsChecked = false; } } } }
static void OnGroupNameChanged(BindableObject bindable, object oldValue, object newValue) { RadioBehavior behavior = (RadioBehavior)bindable; string oldGroupName = (string)oldValue; string newGroupName = (string)newValue; if (String.IsNullOrEmpty(oldGroupName)) { // Remove the Behavior from the default group. defaultGroup.Remove(behavior); } else { // Remove the RadioBehavior from the radioGroups collection. List <RadioBehavior> behaviors = radioGroups[oldGroupName]; behaviors.Remove(behavior); // Get rid of the collection if it's empty. if (behaviors.Count == 0) { radioGroups.Remove(oldGroupName); } } if (String.IsNullOrEmpty(newGroupName)) { // Add the new Behavior to the default group. defaultGroup.Add(behavior); } else { List <RadioBehavior> behaviors = null; if (radioGroups.ContainsKey(newGroupName)) { // Get the named group. behaviors = radioGroups[newGroupName]; } else { // If that group doesn't exist, create it. behaviors = new List <RadioBehavior>(); radioGroups.Add(newGroupName, behaviors); } // Add the Behavior to the group. behaviors.Add(behavior); } }