Skip to content

Commit 342afbc

Browse files
authored
Add bindings for HyperlinkButton (#451)
1 parent 99f16f0 commit 342afbc

File tree

5 files changed

+64
-0
lines changed

5 files changed

+64
-0
lines changed

src/Avalonia.FuncUI.ControlCatalog/Avalonia.FuncUI.ControlCatalog/Avalonia.FuncUI.ControlCatalog.fsproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
<Compile Include="Views\Tabs\FlyoutDemo.fs" />
3030
<Compile Include="Views\Tabs\DragDropDemo.fs" />
3131
<Compile Include="Views\Tabs\AttachedEventDemo.fs" />
32+
<Compile Include="Views\Tabs\HyperlinkButtonDemo.fs" />
3233
<Compile Include="Views\MainView.fs" />
3334
<Compile Include="ControlCatalog.fs" />
3435
<AvaloniaResource Include="**\*.xaml" />

src/Avalonia.FuncUI.ControlCatalog/Avalonia.FuncUI.ControlCatalog/Views/MainView.fs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ module MainView =
6464
TabItem.header "Gridsplitter Demo"
6565
TabItem.content (ViewBuilder.Create<GridSplitterDemo.Host>([]))
6666
]
67+
TabItem.create [
68+
TabItem.header "HyperlinkButton Demo"
69+
TabItem.content (ViewBuilder.Create<HyperlinkButtonDemo.Host>([]))
70+
]
6771
TabItem.create [
6872
TabItem.header "NumericUpDown Demo"
6973
TabItem.content (ViewBuilder.Create<NumericUpDownDemo.Host>([]))
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
namespace Avalonia.FuncUI.ControlCatalog.Views
2+
3+
open Elmish
4+
open Avalonia.Controls
5+
open Avalonia.FuncUI.DSL
6+
open Avalonia.FuncUI
7+
open Avalonia.FuncUI.Elmish
8+
9+
module HyperlinkButtonDemo =
10+
11+
let update _ _ = ()
12+
13+
let view _ _ =
14+
StackPanel.create [
15+
StackPanel.children [
16+
TextBlock.create [
17+
TextBlock.text "Hyperlink samples"
18+
]
19+
20+
HyperlinkButton.create [
21+
HyperlinkButton.navigateUri (System.Uri("https://funcui.avaloniaui.net/"))
22+
HyperlinkButton.content "https://funcui.avaloniaui.net/"
23+
]
24+
]
25+
]
26+
27+
type Host() as this =
28+
inherit Hosts.HostControl()
29+
do
30+
Elmish.Program.mkSimple id update view
31+
|> Program.withHost this
32+
|> Program.withConsoleTrace
33+
|> Program.run

src/Avalonia.FuncUI/Avalonia.FuncUI.fsproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@
129129
<Compile Include="DSL\Buttons\ToggleSplitButton.fs" />
130130
<Compile Include="DSL\Buttons\ToggleSwitch.fs" />
131131
<Compile Include="DSL\Buttons\CheckBox.fs" />
132+
<Compile Include="DSL\Buttons\HyperlinkButton.fs" />
132133
<Compile Include="DSL\Remote\RemoteWidget.fs" />
133134
<Compile Include="DSL\RepeatButton.fs" />
134135
<Compile Include="DSL\DatePicker.fs" />
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
namespace Avalonia.FuncUI.DSL
2+
3+
[<AutoOpen>]
4+
module HyperlinkButton =
5+
open Avalonia.Controls
6+
open Avalonia.FuncUI.Types
7+
open Avalonia.FuncUI.Builder
8+
9+
let create (attrs: IAttr<HyperlinkButton> list): IView<HyperlinkButton> =
10+
ViewBuilder.Create<HyperlinkButton>(attrs)
11+
12+
type HyperlinkButton with
13+
14+
/// <summary>
15+
/// Sets a value indicating whether the <see cref="navigateUri"/> has been visited.
16+
/// </summary>
17+
static member isVisited<'t when 't :> HyperlinkButton>(value: bool) : IAttr<'t> =
18+
AttrBuilder<'t>.CreateProperty<bool>(HyperlinkButton.IsVisitedProperty, value, ValueNone)
19+
20+
/// <summary>
21+
/// Gets or sets the Uniform Resource Identifier (URI) automatically navigated to when the
22+
/// <see cref="HyperlinkButton"/> is clicked.
23+
/// </summary>
24+
static member navigateUri<'t when 't :> HyperlinkButton>(value: System.Uri) : IAttr<'t> =
25+
AttrBuilder<'t>.CreateProperty<System.Uri>(HyperlinkButton.NavigateUriProperty, value, ValueNone)

0 commit comments

Comments
 (0)