private void RegisterRadioButton(RadioButton_t radioButton, RadioButtonViewModel controlViewModel) { string groupName = radioButton.RadioGroup; if (!string.IsNullOrEmpty(groupName)) { RadioButtonGroupManager groupManager; if (_radioButtonGroups.Contains(groupName)) { groupManager = _radioButtonGroups[groupName]; } else { groupManager = _radioButtonGroups.AddGroup(groupName); } groupManager.RegisterRadioButton(controlViewModel); controlViewModel.RadioButtonGroupManager = groupManager; } }
// This method looks for all the radio buttons in the same group as the supplied radio button // and if there are only two private void SetCompanionRadioButton(RadioButton_t radioButton) { IEnumerable <RadioButton_t> radioButtons; // Approach 1 - use the radio button group name if (radioButton.RadioGroup != null) { radioButtons = (from c in _controls.Values where c.Id != radioButton.Id && c is RadioButton_t && (c as RadioButton_t).RadioGroup == radioButton.RadioGroup select c as RadioButton_t); } else { // Approach 2 - look for radio buttons on the same panel radioButtons = (from c in radioButton.OwningStrategyPanel.Controls where c.Id != radioButton.Id && c is RadioButton_t select c as RadioButton_t); } if (radioButtons.Count() == 1) { radioButtons.First().SetValue(true); } }
/// <summary> /// Renders the supplied RadioButton_t as XAML. /// </summary> /// <param name="control">RadioButton_t to render.</param> public void Visit(RadioButton_t control) { RadioButtonRenderer.Render(_writer, control); }
/// <summary> /// Initializes a new instance of <see cref="RadioButtonViewModel"/>. /// </summary> /// <param name="control">Underlying <see cref="RadioButton_t"/> for this RadioButtonViewModel.</param> /// <param name="referencedParameter">Parameter that the RadioButton_t refers to.</param> public RadioButtonViewModel(RadioButton_t control, IParameter referencedParameter) : base(control, referencedParameter) { }