WidgetHandler<TWidget>
References- WidgetHandler<TControl, TWidget>
- WidgetHandler<TControl, TWidget, TCallback>
- ThemedControlHandler<TControl, TWidget, TCallback>
- ThemedContainerHandler<TControl, TWidget, TCallback>
- ThemedSegmentedItemHandler<TWidget, TCallback>
Nothing matches.
Base platform handler for widgets
Remarks: This is the base class for platform handlers. It is used to help wire up events and provide base functionality of a widget. If you are creating an InstanceWidget, you should use WidgetHandler<T, W>.
Type parameters:
| TWidget | Type of widget the handler is for where Widget |
Example:This example shows how to implement a platform handler for a widget called StaticWidget
// override the class and implement widget-specific interface
public MyStaticWidgetHandler : WidgetHandler<StaticWidget>, IStaticWidget
{
// implement IStaticWidget's properties and methods
}See Also: WidgetHandler<T, W>
Properties
Callback
#Gets the callback object for the control
Remarks: This object is typically a single static instance that is used by the platform handlers to call private or protected methods on the widget, such as protected event methods e.g. protected virtual void OnClick(EventArgs e)
Value: The callback.
Gets or sets the widget instance
NativeHandle
#public virtual nint NativeHandle { get; }
Gets the native platform-specific handle for integration purposes
Value: The native handle.
Implements: NativeHandle
Methods
AttachEvent
#Attaches the specified event to the platform-specific control
Remarks: Implementors should override this method to handle any events that the widget supports. Ensure to call the base class' implementation if the event is not one the specific widget supports, so the base class' events can be handled as well.
Parameters:
| id (string) | Identifier of the event |
Detaches an event from the platform-specific control, undoing AttachEvent(string).
Remarks: Implementors can override this for events that hold onto something worth giving back while they are attached, such as a system wide hook. Most events cost nothing to leave attached for the life of the widget, which is why the default is to refuse. Only reached for events whose remove accessor uses PropertyStore.RemoveHandlerEvent(string, Delegate), and never for an event that is attached because the widget overrides its On[Event] method.
Parameters:
| id (string) | Identifier of the event |
Returns: True if the event was detached, false if this platform can't detach it, in which case it stays attached and won't be attached again on a later subscription.
Dispose
#public void Dispose()
Disposes this object
Remarks: To handle disposal logic, use the Dispose(bool) method.
Dispose
#Disposes the object
Parameters:
| disposing (bool) | True when disposed manually, false if disposed via the finalizer |
void IHandler.Initialize()
HandleEvent
#Called to handle a specific event
Remarks: Most events are late bound by this method. Instead of wiring all events, this will be called with an event string that is defined by the control. This is called automatically when attaching to events, but must be called manually when users of the control only override the event's On... method. Override the AttachEvent(string) to attach your events
Parameters:
| id (string) | ID of the event to handle |
| defaultEvent (bool = false) | True if the event is default (e.g. overridden or via an event handler subscription) |
Implements: HandleEvent
See Also: AttachEvent(string)
Initialize
#protected virtual void Initialize()
Called to initialize this widget after it has been constructed
Remarks: Override this to initialize any of the platform objects. This is called in the widget constructor, after all of the widget's constructor code has been called.
IsEventHandled
#Gets a value indicating that the specified event is handled
Parameters:
| id (string) | Identifier of the event |
Returns: True if the event is handled, otherwise false
OnInitializeComplete
#protected virtual void OnInitializeComplete()
Called after initialization is complete
Remarks: Override this to perform any logic after the handler is fully initialized, but before returning from the construction of the widget. This by default applies the any styles for the handler.
Called when the last subscriber to an event has been removed, giving DetachEvent(string) the chance to stop listening for it.
Remarks: Override DetachEvent(string) rather than this, the same way AttachEvent(string) is overridden rather than HandleEvent(string, bool).
Parameters:
| id (string) | ID of the event to stop handling |
Implements: UnhandleEvent