Class SegmentedControl
Forms9Patch Material Segmented Control.
Inheritance
Implements
Inherited Members
Namespace: Forms9Patch
Assembly: Forms9Patch.dll
Syntax
[ContentProperty("Segments")]
public class SegmentedControl : ManualLayout, INotifyPropertyChanged, IDynamicResourceHandler, IElement, INameScope, INavigationProxy, IStyleSelectable, IAnimatable, IResourcesProvider, IStyleElement, IFlowDirectionController, IPropertyPropagationController, IVisualController, ITabStopElement, IStylable, IViewController, IVisualElementController, IElementController, IGestureController, IGestureRecognizers, ILayout, ILayoutController, IPaddingElement, IViewContainer<View>, ILayout, IBackground, IShape, IElement, ILabelStyle, IFontElement, IDisposable
Constructors
SegmentedControl()
Initializes a new instance of the SegmentedControl class.
Declaration
public SegmentedControl()
Fields
AutoFitProperty
backing store for AutoFit property
Declaration
public static readonly BindableProperty AutoFitProperty
Field Value
Type | Description |
---|---|
BindableProperty |
BackgroundColorProperty
Backing store for the Button.BackgroundColor bindable property.
Declaration
public static readonly BindableProperty BackgroundColorProperty
Field Value
Type | Description |
---|---|
BindableProperty |
DarkThemeProperty
Backing store for the Button.DarkTheme property.
Declaration
public static readonly BindableProperty DarkThemeProperty
Field Value
Type | Description |
---|---|
BindableProperty |
FontAttributesProperty
Backing store for the Button.FontAttributes bindable property.
Declaration
public static readonly BindableProperty FontAttributesProperty
Field Value
Type | Description |
---|---|
BindableProperty |
FontColorProperty
Use TextColorProperty
Declaration
[Obsolete("Use TextColorProperty")]
public static readonly BindableProperty FontColorProperty
Field Value
Type | Description |
---|---|
BindableProperty |
FontFamilyProperty
Backing store for the Button.FontFamiily bindable property.
Declaration
public static readonly BindableProperty FontFamilyProperty
Field Value
Type | Description |
---|---|
BindableProperty |
FontSizeProperty
Backing store for the Button.FontSize bindable property.
Declaration
public static readonly BindableProperty FontSizeProperty
Field Value
Type | Description |
---|---|
BindableProperty |
GroupToggleBehaviorProperty
The backing store for the MaterialSegmentControl's ToggleBehavior property.
Declaration
public static readonly BindableProperty GroupToggleBehaviorProperty
Field Value
Type | Description |
---|---|
BindableProperty |
HapticEffectModeProperty
The haptic mode property.
Declaration
public static readonly BindableProperty HapticEffectModeProperty
Field Value
Type | Description |
---|---|
BindableProperty |
HapticEffectProperty
The haptic effect property.
Declaration
public static readonly BindableProperty HapticEffectProperty
Field Value
Type | Description |
---|---|
BindableProperty |
HasTightSpacingProperty
The has tight spacing property.
Declaration
public static readonly BindableProperty HasTightSpacingProperty
Field Value
Type | Description |
---|---|
BindableProperty |
HorizontalTextAlignmentProperty
Backing store for the horizontal text alignment property.
Declaration
public static readonly BindableProperty HorizontalTextAlignmentProperty
Field Value
Type | Description |
---|---|
BindableProperty |
IconColorProperty
Backing store for SegmentedControl IconColor property
Declaration
public static readonly BindableProperty IconColorProperty
Field Value
Type | Description |
---|---|
BindableProperty |
IconFontFamilyProperty
Backing store for IconFontFamily property
Declaration
public static readonly BindableProperty IconFontFamilyProperty
Field Value
Type | Description |
---|---|
BindableProperty |
IconFontSizeProperty
Backing store for SegmentedControl IconFontSize property
Declaration
public static readonly BindableProperty IconFontSizeProperty
Field Value
Type | Description |
---|---|
BindableProperty |
IntraSegmentOrientationProperty
The backing store for the segments orientation property.
Declaration
public static readonly BindableProperty IntraSegmentOrientationProperty
Field Value
Type | Description |
---|---|
BindableProperty |
IntraSegmentSpacingProperty
The backing store for the intra segment spacing property.
Declaration
public static readonly BindableProperty IntraSegmentSpacingProperty
Field Value
Type | Description |
---|---|
BindableProperty |
IsClippedProperty
Backing store for the IsClipped property
Declaration
public static readonly BindableProperty IsClippedProperty
Field Value
Type | Description |
---|---|
BindableProperty |
IsLongPressEnabledProperty
The is long press enabled property.
Declaration
public static readonly BindableProperty IsLongPressEnabledProperty
Field Value
Type | Description |
---|---|
BindableProperty |
LineBreakModeProperty
backing store for LineBreakMode property
Declaration
public static readonly BindableProperty LineBreakModeProperty
Field Value
Type | Description |
---|---|
BindableProperty |
LinesProperty
backing store for Lines property
Declaration
public static readonly BindableProperty LinesProperty
Field Value
Type | Description |
---|---|
BindableProperty |
MinFontSizeProperty
backing store for MinFontSize property
Declaration
public static readonly BindableProperty MinFontSizeProperty
Field Value
Type | Description |
---|---|
BindableProperty |
OrientationProperty
Backing store for the Orienation property
Declaration
public static readonly BindableProperty OrientationProperty
Field Value
Type | Description |
---|---|
BindableProperty |
PaddingProperty
Identifies the Padding bindable property.
Declaration
public static readonly BindableProperty PaddingProperty
Field Value
Type | Description |
---|---|
BindableProperty |
SelectedBackgroundColorProperty
Backing store for the Selected.BackgroundColor property.
Declaration
public static readonly BindableProperty SelectedBackgroundColorProperty
Field Value
Type | Description |
---|---|
BindableProperty |
SelectedFontColorProperty
OBSOLETE: Use SelectedTextColorProperty
Declaration
[Obsolete("Use SelectedTextColorProperty")]
public static readonly BindableProperty SelectedFontColorProperty
Field Value
Type | Description |
---|---|
BindableProperty |
SelectedTextColorProperty
The selected text color property.
Declaration
public static readonly BindableProperty SelectedTextColorProperty
Field Value
Type | Description |
---|---|
BindableProperty |
SeparatorWidthProperty
The backing store for the MaterialSegmentControl's SeparatorWidth property.
Declaration
public static readonly BindableProperty SeparatorWidthProperty
Field Value
Type | Description |
---|---|
BindableProperty |
SoundEffectModeProperty
Backing store for the sound effect mode property.
Declaration
public static readonly BindableProperty SoundEffectModeProperty
Field Value
Type | Description |
---|---|
BindableProperty |
SoundEffectProperty
The backing store for the sound effect property.
Declaration
public static readonly BindableProperty SoundEffectProperty
Field Value
Type | Description |
---|---|
BindableProperty |
StickyBehaviorProperty
OBSOLETE: Use ToggleBehaviorProperty instead.
Declaration
[Obsolete("StickyBehavior property is obsolete, use ToggleBehavior instead", true)]
public static BindableProperty StickyBehaviorProperty
Field Value
Type | Description |
---|---|
BindableProperty |
SyncSegmentFontSizesProperty
The size segment fonts equally property.
Declaration
public static readonly BindableProperty SyncSegmentFontSizesProperty
Field Value
Type | Description |
---|---|
BindableProperty |
TextColorProperty
Backing store for the TextColor bindable property.
Declaration
public static readonly BindableProperty TextColorProperty
Field Value
Type | Description |
---|---|
BindableProperty |
TintIconProperty
The tint image property backing store.
Declaration
public static readonly BindableProperty TintIconProperty
Field Value
Type | Description |
---|---|
BindableProperty |
TintImageProperty
OBSOLETE: Use TintIconProperty
Declaration
[Obsolete("Use TintIconProperty", true)]
public static readonly BindableProperty TintImageProperty
Field Value
Type | Description |
---|---|
BindableProperty |
TrailingIconProperty
Backing store for the trailing image property.
Declaration
public static readonly BindableProperty TrailingIconProperty
Field Value
Type | Description |
---|---|
BindableProperty |
TrailingImageProperty
OBSOLETE: Use TrailingIconProperty
Declaration
[Obsolete("Use TrailingIconProperty")]
public static readonly BindableProperty TrailingImageProperty
Field Value
Type | Description |
---|---|
BindableProperty |
VerticalTextAlignmentProperty
Backing store for the vertical text alignment property.
Declaration
public static readonly BindableProperty VerticalTextAlignmentProperty
Field Value
Type | Description |
---|---|
BindableProperty |
Properties
AutoFit
Gets/Sets the AutoFit property
Declaration
public AutoFit AutoFit { get; set; }
Property Value
Type | Description |
---|---|
AutoFit |
BackgroundColor
Gets or sets the color of the background.
Declaration
public Color BackgroundColor { get; set; }
Property Value
Type | Description |
---|---|
Color | The color of the background. |
DarkTheme
Gets or sets a value indicating whether this Button if for a dark theme.
Declaration
public bool DarkTheme { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
|
FontAttributes
Gets or sets the font attributes.
Declaration
public FontAttributes FontAttributes { get; set; }
Property Value
Type | Description |
---|---|
FontAttributes | The font attributes. |
FontColor
OBSOLETE: Use TextColor
Declaration
[Obsolete("Use TextColor")]
public Color FontColor { get; set; }
Property Value
Type | Description |
---|---|
Color | The color of the font. |
FontFamily
Gets or sets the font family.
Declaration
public string FontFamily { get; set; }
Property Value
Type | Description |
---|---|
String | The font family. |
FontSize
Gets or sets the size of the font.
Declaration
public double FontSize { get; set; }
Property Value
Type | Description |
---|---|
Double | The size of the font. |
GroupToggleBehavior
Gets or sets the MaterialSegmentControl's Toggle behavior.
Declaration
public GroupToggleBehavior GroupToggleBehavior { get; set; }
Property Value
Type | Description |
---|---|
GroupToggleBehavior | The Toggle behavior (None, Radio, Multiselect). |
HapticEffect
Gets or sets the haptic effect.
Declaration
public HapticEffect HapticEffect { get; set; }
Property Value
Type | Description |
---|---|
HapticEffect | The haptic effect. |
HapticEffectMode
Gets or sets the haptic mode.
Declaration
public EffectMode HapticEffectMode { get; set; }
Property Value
Type | Description |
---|---|
EffectMode | The haptic mode. |
HasTightSpacing
Gets or sets if the Icon/Image is close (TightSpacing) to text or at edge (not TightSpacing) of button.
Declaration
public bool HasTightSpacing { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
|
HorizontalTextAlignment
Gets or sets the horizontal text alignment.
Declaration
public TextAlignment HorizontalTextAlignment { get; set; }
Property Value
Type | Description |
---|---|
TextAlignment | The horizontal text alignment. |
IconColor
controls value of .IconColor property
Declaration
public Color IconColor { get; set; }
Property Value
Type | Description |
---|---|
Color |
IconFontFamily
Sets the font used for rendering the IconText
Declaration
public string IconFontFamily { get; set; }
Property Value
Type | Description |
---|---|
String |
IconFontSize
controls value of .IconFontSize property
Declaration
public double IconFontSize { get; set; }
Property Value
Type | Description |
---|---|
Double |
IntraSegmentOrientation
Gets or sets the orientation of elements within the segments.
Declaration
public StackOrientation IntraSegmentOrientation { get; set; }
Property Value
Type | Description |
---|---|
StackOrientation | The orientation of the elements within the segments. |
IntraSegmentSpacing
Gets or sets the intra segment spacing.
Declaration
public double IntraSegmentSpacing { get; set; }
Property Value
Type | Description |
---|---|
Double | The intra segment spacing. |
IsClipped
Gets or sets a value indicating whether any of the contents of this SegmentedControl is clipped.
Declaration
public bool IsClipped { get; }
Property Value
Type | Description |
---|---|
Boolean |
|
IsLongPressEnabled
Gets or sets a value indicating whether this SegmentedControl has long press enabled.
Declaration
public bool IsLongPressEnabled { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
|
LineBreakMode
Gets/Sets the LineBreakMode property
Declaration
public LineBreakMode LineBreakMode { get; set; }
Property Value
Type | Description |
---|---|
LineBreakMode |
Lines
Gets/Sets the Lines property
Declaration
public int Lines { get; set; }
Property Value
Type | Description |
---|---|
Int32 |
MinFontSize
Gets/Sets the MinFontSize property
Declaration
public double MinFontSize { get; set; }
Property Value
Type | Description |
---|---|
Double |
Orientation
controls the orientation of the segments relative to eachother
Declaration
public StackOrientation Orientation { get; set; }
Property Value
Type | Description |
---|---|
StackOrientation |
Padding
Gets or sets the padding for SegmentedControl's segments.
Declaration
public Thickness Padding { get; set; }
Property Value
Type | Description |
---|---|
Thickness | The Thickness values for the layout. The default value is a Thickness with all values set to 0. |
Segments
The container for the Segmented Control's buttons.
Declaration
public IList<Segment> Segments { get; set; }
Property Value
Type | Description |
---|---|
IList<Segment> | The buttons. |
SelectedBackgroundColor
Gets or sets the background color used when selected.
Declaration
public Color SelectedBackgroundColor { get; set; }
Property Value
Type | Description |
---|---|
Color | The selected background. |
SelectedFontColor
OBSOLETE: Use SelectedTextColor property
Declaration
[Obsolete("Use SelectedTextColor")]
public Color SelectedFontColor { get; set; }
Property Value
Type | Description |
---|---|
Color | The color of the selected font. |
SelectedIndexes
Gets the selected index(es).
Declaration
public List<int> SelectedIndexes { get; }
Property Value
Type | Description |
---|---|
List<Int32> | The selected index(es). |
SelectedSegments
Gets the selected segments(s).
Declaration
public List<Segment> SelectedSegments { get; }
Property Value
Type | Description |
---|---|
List<Segment> | The selected segment(s). |
SelectedTextColor
Gets or sets the color of the selected font.
Declaration
public Color SelectedTextColor { get; set; }
Property Value
Type | Description |
---|---|
Color | The color of the selected font. |
SeparatorWidth
Gets or sets the width of the separator. Uses OutlineWidth by default (-1).
Declaration
public float SeparatorWidth { get; set; }
Property Value
Type | Description |
---|---|
Single | The width of the separator. |
SoundEffect
Gets or sets the sound effect played when a segment is tapped
Declaration
public SoundEffect SoundEffect { get; set; }
Property Value
Type | Description |
---|---|
SoundEffect | The sound effect. |
SoundEffectMode
Gets or sets the sound effect is perfomed when a segment is tapped
Declaration
public EffectMode SoundEffectMode { get; set; }
Property Value
Type | Description |
---|---|
EffectMode | The sound effect mode. |
StickyBehavior
OBSOLETE: Use ToggleBehavior instead.
Declaration
[Obsolete("StickyBehavior property is obsolete, use ToggleBehavior instead", true)]
public bool StickyBehavior { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
SyncSegmentFontSizes
Gets or sets a value indicating whether this SegmentedControl size segment fonts equally.
Declaration
public bool SyncSegmentFontSizes { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
|
TextColor
Gets or sets the color of the font.
Declaration
public Color TextColor { get; set; }
Property Value
Type | Description |
---|---|
Color | The color of the font. |
TintIcon
Will the TextColor be applied to the IconImage image?
Declaration
public bool TintIcon { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
|
TintImage
OBSOLETE: Use TintIcon property
Declaration
[Obsolete("Use TintIcon", true)]
public bool TintImage { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
TrailingIcon
Gets or sets if the image is to be rendered after the text.
Declaration
public bool TrailingIcon { get; set; }
Property Value
Type | Description |
---|---|
Boolean | default=false |
TrailingImage
OBSOLETE: Use TrailingIcon
Declaration
[Obsolete("Use TrailingIcon")]
public bool TrailingImage { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
VerticalTextAlignment
Gets or sets the vertical text alignment.
Declaration
public TextAlignment VerticalTextAlignment { get; set; }
Property Value
Type | Description |
---|---|
TextAlignment | The vertical text alignment. |
Methods
CheckIsClipped(Double, Double)
tests if the contents of a segment is clipped
Declaration
public bool CheckIsClipped(double width = -1, double height = -1)
Parameters
Type | Name | Description |
---|---|---|
Double | width | |
Double | height |
Returns
Type | Description |
---|---|
Boolean |
DeselectAll()
Deselects all segments.
Declaration
public void DeselectAll()
DeselectIndex(Int32)
Deselected the segment at index
Declaration
public void DeselectIndex(int index)
Parameters
Type | Name | Description |
---|---|---|
Int32 | index |
Dispose()
Dispose of Forms9Patch.SegmentedControl element.
Declaration
public void Dispose()
Dispose(Boolean)
Dispose the specified disposing.
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
Boolean | disposing | Disposing. |
GetMinSize()
What is the smallest that this control can be rendered (labels are 1 line)
Declaration
public Size GetMinSize()
Returns
Type | Description |
---|---|
Size |
IsIndexSelected(Int32)
Answers the question: Is an index selected?
Declaration
public bool IsIndexSelected(int index)
Parameters
Type | Name | Description |
---|---|---|
Int32 | index |
Returns
Type | Description |
---|---|
Boolean |
LayoutChildren(Double, Double, Double, Double)
Positions and sizes the children of a Layout.
Declaration
protected override void LayoutChildren(double x, double y, double width, double height)
Parameters
Type | Name | Description |
---|---|---|
Double | x | A value representing the x coordinate of the child region bounding box. |
Double | y | A value representing the y coordinate of the child region bounding box. |
Double | width | A value representing the width of the child region bounding box. |
Double | height | A value representing the height of the child region bounding box. |
Overrides
Remarks
Implementors wishing to change the default behavior of a Layout should override this method. It is suggested to still call the base method and modify its calculated results.
OnBindingContextChanged()
Called when BindingContext is changed
Declaration
protected override void OnBindingContextChanged()
Overrides
OnMeasure(Double, Double)
Processes a measurement request
Declaration
protected override SizeRequest OnMeasure(double widthConstraint, double heightConstraint)
Parameters
Type | Name | Description |
---|---|---|
Double | widthConstraint | |
Double | heightConstraint |
Returns
Type | Description |
---|---|
SizeRequest |
Overrides
OnPropertyChanged(String)
Call this method from a child class to notify that a change happened on a property.
Declaration
protected override void OnPropertyChanged(string propertyName = null)
Parameters
Type | Name | Description |
---|---|---|
String | propertyName | The name of the property that changed. |
Overrides
SelectAll()
Selects all segments
Declaration
public void SelectAll()
SelectIndex(Int32)
Selects the segment at index.
Declaration
public void SelectIndex(int index)
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | segment index. |
TapIndex(Int32)
Taps the index.
Declaration
public void TapIndex(int index)
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | Index. |
Events
SegmentLongPressed
Occurs when segment long pressed.
Declaration
public event SegmentedControlEventHandler SegmentLongPressed
Event Type
Type | Description |
---|---|
SegmentedControlEventHandler |
SegmentLongPressing
Occurs when segment long pressing.
Declaration
public event SegmentedControlEventHandler SegmentLongPressing
Event Type
Type | Description |
---|---|
SegmentedControlEventHandler |
SegmentSelected
Occurs when one of the segments is selected.
Declaration
public event SegmentedControlEventHandler SegmentSelected
Event Type
Type | Description |
---|---|
SegmentedControlEventHandler |
SegmentTapped
Occurs when one of the segments is tapped.
Declaration
public event SegmentedControlEventHandler SegmentTapped
Event Type
Type | Description |
---|---|
SegmentedControlEventHandler |