All Projects → AvaloniaCommunity → Avalonia.funcui

AvaloniaCommunity / Avalonia.funcui

Licence: mit
Develop cross-plattform MVU GUI Applications using F# and Avalonia!

Programming Languages

fsharp
127 projects

Labels

Avalonia FuncUI

Avalonia FuncUI

Develop cross-platform MVU GUI Applications using F# and Avalonia!

GitHub top language GitHub repo size


(Application was created using Avalonia.FuncUI!)

About

This library allows you to write cross-platform GUI Applications entirely in F# - No XAML, but a declarative Elm-like DSL. MVU (Model-View-Update) architecture support is built in, and bindings to use it with Elmish are also ready to use.

Getting started

Contributing

Please contribute to this library through issue reports, pull requests, code reviews, documentation, and discussion.

Example

Below is the code of a simple counter app (using the Avalonia.FuncUI.Elmish package).

module Counter =

    type CounterState = {
        count : int
    }

    let init = {
        count = 0
    }

    type Msg =
    | Increment
    | Decrement

    let update (msg: Msg) (state: CounterState) : CounterState =
        match msg with
        | Increment -> { state with count =  state.count + 1 }
        | Decrement -> { state with count =  state.count - 1 }
    
    let view (state: CounterState) (dispatch): IView =
        DockPanel.create [
            DockPanel.children [
                Button.create [
                    Button.onClick (fun _ -> dispatch Increment)
                    Button.content "click to increment"
                ]
                Button.create [
                    Button.onClick (fun _ -> dispatch Decrement)
                    Button.content "click to decrement" 
                ]
                TextBlock.create [
                    TextBlock.dock Dock.Top
                    TextBlock.text (sprintf "the count is %i" state.count)
                ]
            ]
        ]    
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].