Skip to content

Commit

Permalink
Add attributes to a view (#351)
Browse files Browse the repository at this point in the history
  • Loading branch information
marklam committed Sep 29, 2023
1 parent eaa5191 commit 39587cc
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/Avalonia.FuncUI/DSL/View.fs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ type View () =
View.ConstructorArgs = view.ConstructorArgs
View.Outlet = view.Outlet }

/// <summary>
/// <summary>
/// Creates a new IView&lt;'view&gt; with the given attributes and outlet.
/// <example>
/// <code>
Expand Down Expand Up @@ -152,4 +152,26 @@ type View () =
View.ViewKey = view.ViewKey
View.Attrs = view.Attrs
View.ConstructorArgs = constructorArgs
View.Outlet = view.Outlet }

/// <summary>
/// Creates a new IView&lt;'view&gt; with the given attributes.
/// <example>
/// <code>
/// [
/// ...
/// ]
/// |&gt; MyView.create
/// |&gt; View.withAttrs [ Grid.row 1; Grid.column 2 ]
/// </code>
/// </example>
/// </summary>
static member withAttrs<[<DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)>] 'view when 'view :> AvaloniaObject>
( attrs: IAttr<'view> list )
( view: IView<'view> ) : IView<'view> =

{ View.ViewType = view.ViewType
View.ViewKey = view.ViewKey
View.Attrs = view.Attrs @ attrs
View.ConstructorArgs = view.ConstructorArgs
View.Outlet = view.Outlet }

0 comments on commit 39587cc

Please sign in to comment.