Skip to content

Commit

Permalink
add bindings for 'DataGridTextColumn.width'
Browse files Browse the repository at this point in the history
  • Loading branch information
JaggerJo committed Oct 29, 2023
1 parent 5bbcb7f commit a4b6ca6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Avalonia.FuncUI/DSL/DataGrid.fs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@ module DataGridColumn =
static member cellTheme<'t when 't :> DataGridColumn>(value: ControlTheme) : IAttr<'t> =
AttrBuilder<'t>.CreateProperty<ControlTheme>(DataGridColumn.CellThemeProperty, value, ValueNone)

static member width<'t when 't :> DataGridColumn>(value: DataGridLength) : IAttr<'t> =
AttrBuilder<'t>.CreateProperty<DataGridLength>(
name = "width",
value = value,
getter = ValueSome (fun column -> column.Width),
setter = ValueSome (fun (column, value) -> column.Width <- value),
comparer = ValueNone
)

[<AutoOpen>]
module DataGridBoundColumn =

Expand Down
2 changes: 2 additions & 0 deletions src/Examples/Examples.DataGridPlayground/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@ type Views =
DataGrid.dock Dock.Top
DataGrid.isReadOnly false
DataGrid.items data.Current

DataGrid.columns [
DataGridTextColumn.create [
DataGridTextColumn.header "Name"
DataGridTextColumn.binding (Binding ("Name", BindingMode.TwoWay))
DataGridTextColumn.width (DataGridLength(2, DataGridLengthUnitType.Star))
]
DataGridTemplateColumn.create [
DataGridTemplateColumn.header "Name"
Expand Down

3 comments on commit a4b6ca6

@Aytharn
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, it works!

@Aytharn
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I have to do something similar for gradient brushes and animations?

@JaggerJo
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there are no bindings yet, yes. Feel free to create a PR.

Please sign in to comment.