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

Documentation for attached properties #320

Merged
merged 3 commits into from
Jun 25, 2023
Merged
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
6 changes: 5 additions & 1 deletion src/Avalonia.FuncUI/DSL/Panels/Canvas.fs
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,21 @@ module Canvas =
ViewBuilder.Create<Canvas>(attrs)

type Control with
/// An attached property specifying the distance from the left of the parent Canvas. The applied control should be a child of a Canvas for this property to take effect.
static member left<'t when 't :> Control>(value: double) : IAttr<'t> =
AttrBuilder<'t>.CreateProperty<double>(Canvas.LeftProperty, value, ValueNone)

/// An attached property specifying the distance from the top of the parent Canvas. The applied control should be a child of a Canvas for this property to take effect.
static member top<'t when 't :> Control>(value: double) : IAttr<'t> =
AttrBuilder<'t>.CreateProperty<double>(Canvas.TopProperty, value, ValueNone)

/// An attached property specifying the distance from the right of the parent Canvas. The applied control should be a child of a Canvas for this property to take effect.
static member right<'t when 't :> Control>(value: double) : IAttr<'t> =
AttrBuilder<'t>.CreateProperty<double>(Canvas.RightProperty, value, ValueNone)

/// An attached property specifying the distance from the bottom of the parent Canvas. The applied control should be a child of a Canvas for this property to take effect.
static member bottom<'t when 't :> Control>(value: double) : IAttr<'t> =
AttrBuilder<'t>.CreateProperty<double>(Canvas.BottomProperty, value, ValueNone)

type Canvas with
end
end
3 changes: 2 additions & 1 deletion src/Avalonia.FuncUI/DSL/Panels/DockPanel.fs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ module DockPanel =
ViewBuilder.Create<DockPanel>(attrs)

type Control with
/// An attached property specifying the dock relative to the parent DockPanel. The applied control should be a child of a DockPanel for this property to take effect.
static member dock<'t when 't :> Control>(dock: Dock) : IAttr<'t> =
AttrBuilder<'t>.CreateProperty<Dock>(DockPanel.DockProperty, dock, ValueNone)

type DockPanel with
static member lastChildFill<'t when 't :> DockPanel>(fill: bool) : IAttr<'t> =
AttrBuilder<'t>.CreateProperty<bool>(DockPanel.LastChildFillProperty, fill, ValueNone)
AttrBuilder<'t>.CreateProperty<bool>(DockPanel.LastChildFillProperty, fill, ValueNone)
5 changes: 5 additions & 0 deletions src/Avalonia.FuncUI/DSL/Panels/Grid.fs
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,23 @@ module Grid =
Enumerable.SequenceEqual(a, b, comparer);

type Control with
/// An attached property specifying the row of parent Grid. The applied control should be a child of a Grid for this property to take effect.
static member row<'t when 't :> Control>(row: int) : IAttr<'t> =
AttrBuilder<'t>.CreateProperty<int>(Grid.RowProperty, row, ValueNone)

/// An attached property specifying the row span of parent Grid. The applied control should be a child of a Grid for this property to take effect.
static member rowSpan<'t when 't :> Control>(span: int) : IAttr<'t> =
AttrBuilder<'t>.CreateProperty<int>(Grid.RowSpanProperty, span, ValueNone)

/// An attached property specifying the column of parent Grid. The applied control should be a child of a Grid for this property to take effect.
static member column<'t when 't :> Control>(column: int) : IAttr<'t> =
AttrBuilder<'t>.CreateProperty<int>(Grid.ColumnProperty, column, ValueNone)

/// An attached property specifying the column span of parent Grid. The applied control should be a child of a Grid for this property to take effect.
static member columnSpan<'t when 't :> Control>(span: int) : IAttr<'t> =
AttrBuilder<'t>.CreateProperty<int>(Grid.ColumnSpanProperty, span, ValueNone)

/// An attached property marking the scoping element for shared size for the parent Grid. The applied control should be a child of a Grid for this property to take effect.
static member isSharedSizeScope<'t when 't :> Control>(value: bool) : IAttr<'t> =
AttrBuilder<'t>.CreateProperty<bool>(Grid.IsSharedSizeScopeProperty, value, ValueNone)

Expand Down
Loading