How to create bindings
public static readonly StyledProperty<bool> IsPressedProperty =
AvaloniaProperty.Register<Button, bool>(nameof(IsPressed));/// <summary>
/// Defines the <see cref="Click"/> event.
/// </summary>
public static readonly RoutedEvent<RoutedEventArgs> ClickEvent =
RoutedEvent.Register<Button, RoutedEventArgs>(nameof(Click), RoutingStrategies.Bubble);[<AutoOpen>]
module Button =
(* omitting the other existing open statements for clarity *)
open Avalonia.Controls
open Avalonia.FuncUI.Builder
open Avalonia.FuncUI.Types
(* omitting the other existing open statements for clarity *)
let create(attrs: IAttr<Button> list): IView<Button> =
ViewBuilder.Create<Button>(attrs)
type Button with
(* omitting the other existing bindings for clarity *)
static member isPressed<'t when 't :> Button>(value: bool) : IAttr<'t> =
AttrBuilder<'t>.CreateProperty<bool>(Button.IsPressedProperty, value, ValueNone)
static member onClick<'t when 't :> Button>(func: RoutedEventArgs -> unit, ?subPatchOptions) =
AttrBuilder<'t>.CreateSubscription<RoutedEventArgs>(Button.ClickEvent, func, ?subPatchOptions = subPatchOptions)
(* omitting the other existing bindings for clarity *)Last updated