Xamarin.Forms

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class SfButton

    Show / Hide Table of Contents

    Class SfButton

    Represents the SfButton class.

    Inheritance
    System.Object
    SfBorder
    SfButton
    SfChip
    Inherited Members
    SfBorder.CornerRadiusProperty
    SfBorder.HasShadowProperty
    SfBorder.ShadowColorProperty
    SfBorder.DashArrayProperty
    SfBorder.BorderThicknessProperty
    SfBorder.LayoutChildren(Double, Double, Double, Double)
    SfBorder.CornerRadius
    SfBorder.HasShadow
    SfBorder.ShadowColor
    SfBorder.DashArray
    SfBorder.BorderThickness
    Namespace: Syncfusion.XForms.Buttons
    Assembly: Syncfusion.Buttons.XForms.dll
    Syntax
    public class SfButton : SfBorder, IParentThemeElement, IThemeElement

    Constructors

    SfButton()

    Initializes a new instance of the SfButton class. It is a constructor field.

    Declaration
    public SfButton()

    Fields

    BackgroundColorProperty

    Identifies the BackgroundColor property. This property can be used to change the background color of the SfButton control.

    Declaration
    public static readonly BindableProperty BackgroundColorProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty
    Remarks

    This Xamarin.Forms.BindableProperty is read-only.

    BackgroundGradientProperty

    Gets or sets the gradient background color for button.

    Declaration
    public static readonly BindableProperty BackgroundGradientProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty

    BackgroundImageProperty

    Identifies the BackgroundImage property. This property can be used to set an image as the background of SfButton.

    Declaration
    public static readonly BindableProperty BackgroundImageProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty
    Remarks

    This Xamarin.Forms.BindableProperty is read-only.

    BorderColorProperty

    Identifies the BorderColor property. This property can be used to change the border color of the SfButton control.

    Declaration
    public static readonly BindableProperty BorderColorProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty
    Remarks

    This Xamarin.Forms.BindableProperty is read-only.

    BorderWidthProperty

    Identifies the BorderWidth property. This property can be used to customize the width of SfBorder.

    Declaration
    public static readonly BindableProperty BorderWidthProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty
    Remarks

    This Xamarin.Forms.BindableProperty is read-only.

    CommandParameterProperty

    Identifies the CommandParameter bindable property. It is a parameter to pass to the Command property. This is a bindable property.

    Declaration
    public static readonly BindableProperty CommandParameterProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty
    Remarks

    This bindable property is read-only.

    CommandProperty

    Identifies the Command bindable property. It invokes when the button is activated. The default value is null.

    Declaration
    public static readonly BindableProperty CommandProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty
    Remarks

    This bindable property is read-only.

    ContentProperty

    Identifies the Content property. This property can be used to set custom view to the button control.

    Declaration
    public static readonly BindableProperty ContentProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty
    Remarks

    This bindable property is read-only.

    EnableRippleEffectProperty

    Identifies the EnableRippleEffect property. This property can be used to enable ripple effect of button.

    Declaration
    public static readonly BindableProperty EnableRippleEffectProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty
    Remarks

    This Xamarin.Forms.BindableProperty is read-only.

    FontAttributesProperty

    Identifies the FontAttributes property. This property can be used to change the font of text to either bold or italic.

    Declaration
    public static readonly BindableProperty FontAttributesProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty
    Remarks

    This Xamarin.Forms.BindableProperty is read-only.

    FontFamilyProperty

    Identifies the FontFamily property. This property can be used to change the font family of the text in button.

    Declaration
    public static readonly BindableProperty FontFamilyProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty
    Remarks

    This Xamarin.Forms.BindableProperty is read-only.

    FontSizeProperty

    Identifies the FontSize property. This property can be used to change the font size of the text in button.

    Declaration
    public static readonly BindableProperty FontSizeProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty
    Remarks

    This Xamarin.Forms.BindableProperty is read-only.

    HorizontalTextAlignmentProperty

    Identifies the HorizontalTextAlignment property. This property can be used to change the horizontal position of text in SfButton.

    Declaration
    public static readonly BindableProperty HorizontalTextAlignmentProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty
    Remarks

    This Xamarin.Forms.BindableProperty is read-only.

    ImageAlignmentProperty

    Identifies the ImageAlignment property. This property can be used to change the position of the image in the button control.

    Declaration
    public static readonly BindableProperty ImageAlignmentProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty
    Remarks

    This Xamarin.Forms.BindableProperty is read-only.

    ImageProperty

    Gets or sets a value of the Image. This property can be used to customize the image of the button.

    Declaration
    public static readonly BindableProperty ImageProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty

    ImageSourceProperty

    Identifies the ImageSource property. This property can be used to set an image to the background of the button.

    Declaration
    public static readonly BindableProperty ImageSourceProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty
    Remarks

    This Xamarin.Forms.BindableProperty is read-only.

    ImageWidthProperty

    Identifies the ImageWidth bindable property. This property can be used to customize the width of an imgage in the button control.

    Declaration
    public static readonly BindableProperty ImageWidthProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty
    Remarks

    This Xamarin.Forms.BindableProperty is read-only.

    IsCheckableProperty

    Identifies the IsCheckable property. This property can be used to change the state of the button.

    Declaration
    public static readonly BindableProperty IsCheckableProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty
    Remarks

    This Xamarin.Forms.BindableProperty is read-only.

    IsCheckedProperty

    Identifies the IsChecked property. It indicates whether the button is in the default state in SfButton.

    Declaration
    public static readonly BindableProperty IsCheckedProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty
    Remarks

    This Xamarin.Forms.BindableProperty is read-only.

    PaddingProperty

    Identifies the Padding property. This property can be used to set padding to the sides of button.

    Declaration
    public static readonly BindableProperty PaddingProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty
    Remarks

    This Xamarin.Forms.BindableProperty is read-only.

    PressedBackgroundColorProperty

    Identifies the PressedBackgroundColor property. This property can be used to change the background color of button when clicking.

    Declaration
    public static readonly BindableProperty PressedBackgroundColorProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty
    Remarks

    This Xamarin.Forms.BindableProperty is read-only.

    ShowIconProperty

    Identifies the ShowIcon property. This property can be used to set an icon by setting this property to true.

    Declaration
    public static readonly BindableProperty ShowIconProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty
    Remarks

    This Xamarin.Forms.BindableProperty is read-only.

    TextColorProperty

    Identifies the TextColor property. This property can be used to change the color of text in the SfButton control.

    Declaration
    public static readonly BindableProperty TextColorProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty
    Remarks

    This Xamarin.Forms.BindableProperty is read-only.

    TextProperty

    Identifies the Text property. This property can be used to set text property to the button control.

    Declaration
    public static readonly BindableProperty TextProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty
    Remarks

    This Xamarin.Forms.BindableProperty is read-only.

    VerticalTextAlignmentProperty

    Identifies the VerticalTextAlignment property. This property can be used to change the vertical position of text in SfButton.

    Declaration
    public static readonly BindableProperty VerticalTextAlignmentProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty
    Remarks

    This Xamarin.Forms.BindableProperty is read-only.

    Properties

    BackgroundColor

    Gets or sets the value of the BackgroundColor. This property can be used to change the background color of the SfButton control.

    Declaration
    public Color BackgroundColor { get; set; }
    Property Value
    Type Description
    Xamarin.Forms.Color

    BackgroundGradient

    Gets or sets the gradient background color for button.

    Declaration
    public SfGradientBrush BackgroundGradient { get; set; }
    Property Value
    Type Description
    SfGradientBrush

    BackgroundImage

    Gets or sets the value of the BackgroundImage. This property can be used to set an image as the background of SfButton.

    Declaration
    public ImageSource BackgroundImage { get; set; }
    Property Value
    Type Description
    Xamarin.Forms.ImageSource

    BorderColor

    Gets or sets the value of the BorderColor. This property can be used to change the border color of the SfButton control.

    Declaration
    public Color BorderColor { get; set; }
    Property Value
    Type Description
    Xamarin.Forms.Color

    BorderWidth

    Gets or sets the value of the BorderWidth. This property can be used to customize the width of the SfBorder control.

    Declaration
    public double BorderWidth { get; set; }
    Property Value
    Type Description
    System.Double

    Command

    Gets or sets the value of the Command. It invokes when the button is activated. It is a bindale property.

    Declaration
    public ICommand Command { get; set; }
    Property Value
    Type Description
    System.Windows.Input.ICommand

    The command.

    CommandParameter

    Gets or sets the value of the CommandParameter, which is a parameter to pass the Command property. This is a bindable property.

    Declaration
    public object CommandParameter { get; set; }
    Property Value
    Type Description
    System.Object

    The command parameter.

    Content

    Gets or sets the value of the Content. This property can be used to set custom view to the button control.

    Declaration
    public View Content { get; set; }
    Property Value
    Type Description
    Xamarin.Forms.View

    The content of border.

    EnableRippleEffect

    Gets or sets a value indicating whether the ripple effect of SfButton is enabled or not.

    Declaration
    public bool EnableRippleEffect { get; set; }
    Property Value
    Type Description
    System.Boolean

    The default value is true.

    Remarks

    This property is not supported for UWP and WPF platforms.

    FontAttributes

    Gets or sets the value of FontAttributes. This property can be used to change the font of text in either bold or italic.

    Declaration
    public FontAttributes FontAttributes { get; set; }
    Property Value
    Type Description
    Xamarin.Forms.FontAttributes

    FontFamily

    Gets or sets the value of the FontFamily. This property can be used to change the font family of the text in button.

    Declaration
    public string FontFamily { get; set; }
    Property Value
    Type Description
    System.String

    FontSize

    Gets or sets the value of FontSize. This property can be used to change the font size of the text in button.

    Declaration
    public double FontSize { get; set; }
    Property Value
    Type Description
    System.Double

    HorizontalTextAlignment

    Gets or sets the value of the HorizontalTextAlignment. This property can be used to change the horizontal position of text in SfButton.

    Declaration
    public TextAlignment HorizontalTextAlignment { get; set; }
    Property Value
    Type Description
    Xamarin.Forms.TextAlignment

    Image

    Gets or sets a value of the Image. This property can be used to customize the image of the button.

    Declaration
    public Image Image { get; set; }
    Property Value
    Type Description
    Xamarin.Forms.Image

    ImageAlignment

    Gets or sets the value of the ImageAlignment. This property can be used to set padding to the sides of the button.

    Declaration
    public Alignment ImageAlignment { get; set; }
    Property Value
    Type Description
    Alignment

    ImageSource

    Gets or sets a value of the ImageSoure. This property can be used to set the image to the background of the button.

    Declaration
    public ImageSource ImageSource { get; set; }
    Property Value
    Type Description
    Xamarin.Forms.ImageSource

    ImageWidth

    Gets or sets the value of the width of image icon. This property can be used to customize the width of the Image in button.

    Declaration
    public int ImageWidth { get; set; }
    Property Value
    Type Description
    System.Int32

    IsCheckable

    Gets or sets a value indicating whether the button is in the default state or not. This property can be used to change the state of the button.

    Declaration
    public bool IsCheckable { get; set; }
    Property Value
    Type Description
    System.Boolean

    IsChecked

    Gets or sets a value indicating whether the button is checkable. It is used to check the state of the button.

    Declaration
    public bool IsChecked { get; set; }
    Property Value
    Type Description
    System.Boolean

    Padding

    Gets or sets the value of Padding. This property can be used to set padding to the sides of button.

    Declaration
    public Thickness Padding { get; set; }
    Property Value
    Type Description
    Xamarin.Forms.Thickness

    PressedBackgroundColor

    Gets or sets the value of the PressedBackgroundColor. This property can be used to change the background color of button when clicking.

    Declaration
    public Color PressedBackgroundColor { get; set; }
    Property Value
    Type Description
    Xamarin.Forms.Color

    ShowIcon

    Gets or sets a value indicating whether the image icon of SfButton is visible or not. The icon is in visible state when this property is set to true.

    Declaration
    public bool ShowIcon { get; set; }
    Property Value
    Type Description
    System.Boolean

    The default value is false.

    Text

    Gets or sets a value of the text. This property can be used to set the text input to SfButton.

    Declaration
    public string Text { get; set; }
    Property Value
    Type Description
    System.String

    TextColor

    Gets or sets the value of TextColor. This property can be used to change the color of text in the SfButton control.

    Declaration
    public Color TextColor { get; set; }
    Property Value
    Type Description
    Xamarin.Forms.Color

    VerticalTextAlignment

    Gets or sets the value of the VerticalTextAlignment. This property can be used to change the vertical position of text in SfButton.

    Declaration
    public TextAlignment VerticalTextAlignment { get; set; }
    Property Value
    Type Description
    Xamarin.Forms.TextAlignment

    Methods

    OnMeasure(Double, Double)

    Method is called when a layout measurement happens.

    Declaration
    protected override SizeRequest OnMeasure(double widthConstraint, double heightConstraint)
    Parameters
    Type Name Description
    System.Double widthConstraint

    The width constraint of the control.

    System.Double heightConstraint

    The height constraint of the control.

    Returns
    Type Description
    Xamarin.Forms.SizeRequest

    The size of the control.

    Overrides
    SfBorder.OnMeasure(Double, Double)

    OnPropertyChanged(String)

    This method calls on every property changed.

    Declaration
    protected override void OnPropertyChanged(string propertyName = null)
    Parameters
    Type Name Description
    System.String propertyName

    Property name.

    Events

    Clicked

    It represents the Clicked event handler. This clicked event is hooked when clicking the SfButton control.

    Declaration
    public event EventHandler<EventArgs> Clicked
    Event Type
    Type Description
    System.EventHandler<System.EventArgs>
    Back to top Generated by DocFX
    Copyright © 2001 - 2023 Syncfusion Inc. All Rights Reserved