private static void ChangeOnDP(UserStackPanel d, int num, string target, string contents) { string tmp = contents; if (tmp == null) { return; } string[] ButtonContents = tmp.Split(','); string bindingTarget = target; var tt = LogicalTreeHelper.GetChildren(d); var stackpanel = tt.Cast <FrameworkElement>().ElementAt(0) as StackPanel; if (stackpanel.Children != null) { stackpanel.Children.Clear(); } if (bindingTarget == null) { return; } for (int i = 1; i <= num; i++) { string ttmp = ""; if (i - 1 < ButtonContents.Length) { ttmp = ButtonContents[i - 1]; } ((StackPanel)stackpanel).Children.Add(new CustomRadioButton(bindingTarget, ButtonContents[i - 1], i)); } }
private static void OnRadioButtonContentSetChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { UserStackPanel my = (UserStackPanel)d; ChangeOnDP(my, my.RadioButtonNumber, my.RadioButtonTargetBindingName, (string)e.NewValue); }