Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bindings for HyperlinkButton #451

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<Compile Include="Views\Tabs\FlyoutDemo.fs" />
<Compile Include="Views\Tabs\DragDropDemo.fs" />
<Compile Include="Views\Tabs\AttachedEventDemo.fs" />
<Compile Include="Views\Tabs\HyperlinkButtonDemo.fs" />
<Compile Include="Views\MainView.fs" />
<Compile Include="ControlCatalog.fs" />
<AvaloniaResource Include="**\*.xaml" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ module MainView =
TabItem.header "Gridsplitter Demo"
TabItem.content (ViewBuilder.Create<GridSplitterDemo.Host>([]))
]
TabItem.create [
TabItem.header "HyperlinkButton Demo"
TabItem.content (ViewBuilder.Create<HyperlinkButtonDemo.Host>([]))
]
TabItem.create [
TabItem.header "NumericUpDown Demo"
TabItem.content (ViewBuilder.Create<NumericUpDownDemo.Host>([]))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
namespace Avalonia.FuncUI.ControlCatalog.Views

open Elmish
open Avalonia.Controls
open Avalonia.FuncUI.DSL
open Avalonia.FuncUI
open Avalonia.FuncUI.Elmish

module HyperlinkButtonDemo =

let update _ _ = ()

let view _ _ =
StackPanel.create [
StackPanel.children [
TextBlock.create [
TextBlock.text "Hyperlink samples"
]

HyperlinkButton.create [
HyperlinkButton.navigateUri (System.Uri("https://funcui.avaloniaui.net/"))
HyperlinkButton.content "https://funcui.avaloniaui.net/"
]
]
]

type Host() as this =
inherit Hosts.HostControl()
do
Elmish.Program.mkSimple id update view
|> Program.withHost this
|> Program.withConsoleTrace
|> Program.run
1 change: 1 addition & 0 deletions src/Avalonia.FuncUI/Avalonia.FuncUI.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@
<Compile Include="DSL\Buttons\ToggleSplitButton.fs" />
<Compile Include="DSL\Buttons\ToggleSwitch.fs" />
<Compile Include="DSL\Buttons\CheckBox.fs" />
<Compile Include="DSL\Buttons\HyperlinkButton.fs" />
<Compile Include="DSL\Remote\RemoteWidget.fs" />
<Compile Include="DSL\RepeatButton.fs" />
<Compile Include="DSL\DatePicker.fs" />
Expand Down
25 changes: 25 additions & 0 deletions src/Avalonia.FuncUI/DSL/Buttons/HyperlinkButton.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
namespace Avalonia.FuncUI.DSL

[<AutoOpen>]
module HyperlinkButton =
open Avalonia.Controls
open Avalonia.FuncUI.Types
open Avalonia.FuncUI.Builder

let create (attrs: IAttr<HyperlinkButton> list): IView<HyperlinkButton> =
ViewBuilder.Create<HyperlinkButton>(attrs)

type HyperlinkButton with

/// <summary>
/// Sets a value indicating whether the <see cref="navigateUri"/> has been visited.
/// </summary>
static member isVisited<'t when 't :> HyperlinkButton>(value: bool) : IAttr<'t> =
AttrBuilder<'t>.CreateProperty<bool>(HyperlinkButton.IsVisitedProperty, value, ValueNone)

/// <summary>
/// Gets or sets the Uniform Resource Identifier (URI) automatically navigated to when the
/// <see cref="HyperlinkButton"/> is clicked.
/// </summary>
static member navigateUri<'t when 't :> HyperlinkButton>(value: System.Uri) : IAttr<'t> =
AttrBuilder<'t>.CreateProperty<System.Uri>(HyperlinkButton.NavigateUriProperty, value, ValueNone)
Loading