[TypeConverter(SegmentedItemConverter)] public abstract class SegmentedItem : BindableWidget
Base class for items of the SegmentedButton control.

Constructors

SegmentedItem

#
protected SegmentedItem()
Initializes a new instance of the SegmentedItem class.

SegmentedItem

#
protected SegmentedItem(Command command)
Initializes a new instance of the SegmentedItem class with the specified command.
Remarks: This links the segmented item with the specified command, and will trigger Command.Execute() when the user clicks the item, and enable/disable the menu item based on Command.Enabled. This also supports RadioCommand and CheckCommand, which may be appropriate depending on the current SegmentedButton.SelectionMode. For SegmentedSelectionMode.Multiple, then CheckCommand would be preferred, whereas for SegmentedSelectionMode.Single, RadioCommand would make more sense. Otherwise, use Command if the mode is SegmentedSelectionMode.None. This is not a weak link, so you should not reuse the Command instance for other menu items if you are disposing this segmented item.
command (Command)Command to initialize the menu item with.

Fields

ClickEvent

#
public const string ClickEvent = "SegmentedItem.Click"
Identifier for handlers to attach the Click event.

SelectedChangedEvent

#
public const string SelectedChangedEvent = "SegmentedItem.SelectedChanged"
Identifier for handlers to attach the SelectedChanged event.

Properties

Command

#
public ICommand Command { get; set; }
Gets or sets the command to invoke when the segmented item is pressed.
Remarks: This will invoke the specified command when the segmented item is pressed. The ICommand.CanExecute(object) will also used to set the enabled/disabled state of the segmented item.
The command to invoke.

CommandParameter

#
public object CommandParameter { get; set; }
Gets or sets the parameter to pass to the Command when executing or determining its CanExecute state.

ControlObject

public object ControlObject { get; }
Gets the instance of the platform-specific object
inherited fromWidget
Remarks: This can sometimes be useful to get the platform-specific object. Some handlers may not have any backing object for its functionality, so this may be null. It is more preferred to use the Widget.Handler and cast that to the platform-specific handler class which can give you additional methods and helpers to do common tasks. For example, the Application object's handler for OS X has a AddFullScreenMenuItem property to specify if you want full screen support in your app.

DataContext

public object DataContext { get; set; }
Gets or sets the data context for this widget for binding
inherited fromBindableWidget
Remarks: Subclasses may override the standard behaviour so that hierarchy of widgets can be taken into account. For example, a Control may return the data context of a parent, if it is not set explicitly.
DataContext

Enabled

#
[DefaultValue(true)] public bool Enabled { get; set; }
Gets or sets a value indicating whether this SegmentedItem is enabled.

Handler

public object Handler { get; }
Gets the platform-specific handler for this widget
inherited fromWidget

Image

#
public Image Image { get; set; }
Gets or sets the image to display in this segment.

IsDataContextChanging

public bool IsDataContextChanging { get; set; }
Gets a value indicating that the BindableWidget.DataContext property is changing.
inherited fromBindableWidget
Remarks: This can be used to determine when to allow certain logic during the update of the data context. It is used to disable binding setters on the model when the data context changes so that a binding does not cause the view model to be updated when the state hasn't been fully set yet.
true if the DataContext is currently changing, false otherwise.

IsDisposed

public bool IsDisposed { get; }
Gets or sets a value indicating whether this Widget has been disposed.
inherited fromWidget
Remarks: When the widget is disposed, it can no longer be used.
true if this instance has been disposed; otherwise, false.

NativeHandle

public nint NativeHandle { get; }
Gets the native platform-specific handle for integration purposes
inherited fromWidget

Parent

#
public SegmentedButton Parent { get; }
Gets the parent button this item belongs to.
Remarks: Note this is only set after adding your item to the SegmentedButton.Items collection.
The parent control.

Platform

public Platform Platform { get; }
Gets the platform that was used to create the Widget.Handler for this widget
inherited fromWidget
Remarks: This gets set to the current Platform.Instance during the construction of the object

Properties

public PropertyStore Properties { get; }
Gets the dictionary of properties for this widget
inherited fromWidget

Selected

#
public bool Selected { get; set; }
Gets or sets a value indicating whether this SegmentedItem is selected.

Style

public string Style { get; set; }
Gets or sets the style of this widget
inherited fromWidget
Remarks: Styles allow you to attach custom platform-specific logic to a widget. In your platform-specific assembly, use Add{H} to add the style logic with the same id.
// in your UI
var control = new Button { Style = "mystyle" };

// in your platform assembly
using Eto.Mac.Forms.Controls;

Styles.AddHandler<ButtonHandler>("mystyle", handler => {
	// this is where you can use handler.Control to set properties, handle events, etc.
	handler.Control.BezelStyle = NSBezelStyle.SmallSquare;
});

Text

#
public string Text { get; set; }
Gets or sets the text to display for this segment.

ToolTip

#
public string ToolTip { get; set; }
Gets or sets the ToolTip to display for this segment

Visible

#
[DefaultValue(true)] public bool Visible { get; set; }
Gets or sets a value indicating whether this SegmentedItem is visible.

Width

#
[DefaultValue(-1)] public int Width { get; set; }
Gets or sets the width of this segment, or -1 to auto size.

Methods

Dispose

protected virtual void Dispose(bool disposing)
Handles the disposal of this widget
inherited fromWidget
disposing (bool)True if the caller called Widget.Dispose() manually, false if being called from a finalizer

FindParent<T>

public T FindParent<T>(string id = null)
Finds a control in the parent hierarchy with the specified type and Widget.ID if specified
inherited fromBindableWidget
id (string = null)Identifier of the parent control to find, or null to ignore
The parent if found, or null if not found

FindParent

public Widget FindParent(Type type, string id = null)
Finds a control in the parent hierarchy with the specified type and Widget.ID if specified
inherited fromBindableWidget
type (Type)The type of control to find.
id (string = null)Identifier of the parent control to find, or null to find by type only.
The parent if found, or null if not found.

GetCallback

#
protected override object GetCallback()
Gets an instance of an object used to perform callbacks to the widget from handler implementations
Remarks: The callback should implement the parent class' Widget.ICallback interface so that there only needs to be a single callback for the entire hierarchy. This should return a static instance to avoid having overhead for each instance of your control.
The callback instance to use for this widget

Initialize

protected void Initialize()
Initializes the widget handler
inherited fromWidget
Remarks: This is typically called from the constructor after all of the logic is completed to construct the object. If your handler interface has the AutoInitializeAttribute set to false, then you are responsible for calling this method in your constructor after calling the creation method on your custom handler.

OnDataContextChanged

protected virtual void OnDataContextChanged(EventArgs e)
inherited fromBindableWidget
Remarks: Implementors may override this to fire this event on child widgets in a heirarchy. Alternatively, implement IBindableWidgetContainer for your widget and this will trigger any events on the children automatically. This allows a control to be bound to its own BindableWidget.DataContext, which would be set on one of the parent control(s).
e (EventArgs)Event arguments

OnSelectedChanged

#
protected virtual void OnSelectedChanged(EventArgs e)
Raises the SelectedChanged event.

OnStyleChanged

protected virtual void OnStyleChanged(EventArgs e)
Handles when the Widget.Style is changed.
inherited fromWidget

ToString

public override string ToString()
Gets a string that represents the current object with its ID if specified.
inherited fromWidget
A string value indicating the type and ID (if specified) of this widget.
Object.ToString

Unbind

#
public override void Unbind()
Unbinds any bindings in the BindableWidget.Bindings collection and removes the bindings

UpdateBindings

public virtual void UpdateBindings(BindingUpdateMode mode = BindingUpdateMode.Source)
Updates all bindings in this widget
inherited fromBindableWidget
Remarks: When you implement IBindableWidgetContainer, this will also update bindings for all of its children.
mode (BindingUpdateMode = BindingUpdateMode.Source)

Events

DataContextChanged

public event EventHandler<EventArgs> DataContextChanged
Event to handle when the BindableWidget.DataContext has changed
inherited fromBindableWidget
Remarks: This may be fired in the event of a parent in the hierarchy setting the data context. For example, the Container widget fires this event when it's event is fired.
DataContextChanged

Convertors

OperationResultDescription
implicitCommandSegmentedItemImplicitly converts a command to a segmented item.
implicitImageSegmentedItemImplicitly converts an image to a segmented item.
implicitstringSegmentedItemImplicitly converts a string to a segmented item.