From a4b6ca6b592e08fdaad195a7be949edc1e06c7ff Mon Sep 17 00:00:00 2001 From: Josua Jaeger Date: Sun, 29 Oct 2023 16:58:20 +0100 Subject: [PATCH] add bindings for 'DataGridTextColumn.width' --- src/Avalonia.FuncUI/DSL/DataGrid.fs | 9 +++++++++ src/Examples/Examples.DataGridPlayground/Program.fs | 2 ++ 2 files changed, 11 insertions(+) diff --git a/src/Avalonia.FuncUI/DSL/DataGrid.fs b/src/Avalonia.FuncUI/DSL/DataGrid.fs index 33441a23..928961a6 100644 --- a/src/Avalonia.FuncUI/DSL/DataGrid.fs +++ b/src/Avalonia.FuncUI/DSL/DataGrid.fs @@ -68,6 +68,15 @@ module DataGridColumn = static member cellTheme<'t when 't :> DataGridColumn>(value: ControlTheme) : IAttr<'t> = AttrBuilder<'t>.CreateProperty(DataGridColumn.CellThemeProperty, value, ValueNone) + static member width<'t when 't :> DataGridColumn>(value: DataGridLength) : IAttr<'t> = + AttrBuilder<'t>.CreateProperty( + name = "width", + value = value, + getter = ValueSome (fun column -> column.Width), + setter = ValueSome (fun (column, value) -> column.Width <- value), + comparer = ValueNone + ) + [] module DataGridBoundColumn = diff --git a/src/Examples/Examples.DataGridPlayground/Program.fs b/src/Examples/Examples.DataGridPlayground/Program.fs index ba77f815..0755538b 100644 --- a/src/Examples/Examples.DataGridPlayground/Program.fs +++ b/src/Examples/Examples.DataGridPlayground/Program.fs @@ -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"