protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.Button> e) { // _buttonScheme?.Dispose(); // _buttonScheme = CreateButtonScheme(); base.OnElementChanged(e); //Element.Text = "I am a Custom Visual Renderer"; if (e.NewElement != null) { if (Control == null) { // _defaultButtonScheme = CreateButtonScheme(); SetNativeControl(CreateNativeControl()); // SetControlPropertiesFromProxy(); _buttonTextColorDefaultNormal = Control.TitleColor(UIControlState.Normal); _buttonTextColorDefaultHighlighted = Control.TitleColor(UIControlState.Highlighted); _buttonTextColorDefaultDisabled = Control.TitleColor(UIControlState.Disabled); Control.TouchUpInside += OnButtonTouchUpInside; Control.TouchDown += OnButtonTouchDown; } UpdateFont(); UpdateCornerRadius(); UpdateBorder(); UpdateTextColor(); _buttonLayoutManager?.Update(); ApplyTheme(); } }
protected override void OnElementChanged(ElementChangedEventArgs <Button> e) { // recreate the scheme _buttonScheme?.Dispose(); _buttonScheme = CreateButtonScheme(); base.OnElementChanged(e); if (e.NewElement != null) { if (Control == null) { _defaultButtonScheme = CreateButtonScheme(); SetNativeControl(CreateNativeControl()); Control.TouchUpInside += OnButtonTouchUpInside; Control.TouchDown += OnButtonTouchDown; } UpdateFont(); UpdateCornerRadius(); UpdateBorder(); UpdateTextColor(); _buttonLayoutManager?.Update(); ApplyTheme(); } }
protected override void OnElementChanged(ElementChangedEventArgs <Button> e) { base.OnElementChanged(e); if (e.NewElement != null) { if (Control == null) { AppCompatButton button = CreateNativeControl(); button.SetOnClickListener(this); button.SetOnTouchListener(this); button.AddOnAttachStateChangeListener(this); _textColorSwitcher = new TextColorSwitcher(button.TextColors, e.NewElement.UseLegacyColorManagement()); SetNativeControl(button); } _defaultFontSize = 0f; _buttonLayoutManager?.Update(); UpdateAll(); } }
public override SizeRequest GetDesiredSize(int widthConstraint, int heightConstraint) { _buttonLayoutManager?.Update(); return(base.GetDesiredSize(widthConstraint, heightConstraint)); }