/// <summary> /// 清除数据 /// </summary> public void _Clear() { MyRadioButton radio = null; if (!_DefaultValue.ToStr().IsNullOrEmpty()) { foreach (var rdo in List) { if (rdo._CheckedValue.ToStr().Equals(_DefaultValue)) { radio = rdo; } } } else { if (List.Count > 0) { radio = List[0]; } } if (radio == null) { return; } if (!_Value.ToStr().Equals(radio._CheckedValue.ToStr())) { _Value = radio._CheckedValue; var arge = new RoutedEventArgs(MyRadioListSelectionChangeRoutedEvent, this); RaiseEvent(arge); } }
/// <summary> /// 填充列表 /// </summary> /// <param name="list"></param> public void _SetListFromDataDic(List <DataDicModel> list) { pnlBody.Children.Clear(); this.List = new List <MyRadioButton>(); if (list != null) { foreach (var model in list) { var radio = new MyRadioButton(); radio.Margin = new Thickness(2, 0, 2, 0); radio._CheckedValue = model.val; radio._Text = model.name; radio._Selected += radio_SelectionChange; this.List.Add(radio); pnlBody.Children.Add(radio); } _Clear(); } }