Пример #1
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            if (ButtonBase != null)
            {
                ButtonBase.Checked       -= CheckedHandler;
                ButtonBase.Unchecked     -= UncheckedHandler;
                ButtonBase.Indeterminate -= IndeterminateHandler;

                BindingOperations.ClearBinding(ButtonBase, ToggleButton.IsCheckedProperty);

                ButtonBase.IsEnabledChanged -= IsEnabledHandler;
            }

            ButtonBase = EnforceInstance <ToggleButton>("PART_Button");

            if (ButtonBase != null)
            {
                ButtonBase.Checked       += CheckedHandler;
                ButtonBase.Unchecked     += UncheckedHandler;
                ButtonBase.Indeterminate += IndeterminateHandler;

                var binding = new Binding("IsChecked")
                {
                    Source = this
                };
                ButtonBase.SetBinding(ToggleButton.IsCheckedProperty, binding);

                ButtonBase.IsEnabledChanged += IsEnabledHandler;

                RadioController?.AddElement(ButtonBase, RadioControllerParameter);
            }

            ChangeVisualState(false);
        }
Пример #2
0
 public static void SetRadioController(
     DependencyObject obj,
     RadioController value)
 {
     obj.SetValue(RadioControllerProperty, value);
 }