-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bba2bdf
commit 46d6b34
Showing
3 changed files
with
124 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using System.Linq.Expressions; | ||
|
||
using Avalonia.Controls; | ||
using Avalonia.Controls.Models.TreeDataGrid; | ||
using Avalonia.Experimental.Data; | ||
|
||
namespace DynamicTreeDataGrid.Columns; | ||
|
||
public class DynamicCheckBoxColumn<TModel> : CheckBoxColumn<TModel> | ||
where TModel : class { | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="CheckBoxColumn{TModel}"/> class. | ||
/// </summary> | ||
/// <param name="header">The column header.</param> | ||
/// <param name="getter"> | ||
/// An expression which given a row model, returns a boolean cell value for the column. | ||
/// </param> | ||
/// <param name="setter"> | ||
/// A method which given a row model and a cell value, writes the cell value to the | ||
/// row model. If not supplied then the column will be read-only. | ||
/// </param> | ||
/// <param name="width"> | ||
/// The column width. If null defaults to <see cref="GridLength.Auto"/>. | ||
/// </param> | ||
/// <param name="options">Additional column options.</param> | ||
public DynamicCheckBoxColumn(object? header, | ||
Expression<Func<TModel, bool>> getter, | ||
Action<TModel, bool>? setter = null, | ||
GridLength? width = null, | ||
CheckBoxColumnOptions<TModel>? options = null) : base(header, getter, setter, width, | ||
options) { } | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="CheckBoxColumn{TModel}"/> class that | ||
/// displays a three-state check box. | ||
/// </summary> | ||
/// <param name="header">The column header.</param> | ||
/// <param name="getter"> | ||
/// An expression which given a row model, returns a nullable boolean cell value for the | ||
/// column. | ||
/// </param> | ||
/// <param name="setter"> | ||
/// A method which given a row model and a cell value, writes the cell value to the | ||
/// row model. If not supplied then the column will be read-only. | ||
/// </param> | ||
/// <param name="width"> | ||
/// The column width. If null defaults to <see cref="GridLength.Auto"/>. | ||
/// </param> | ||
/// <param name="options">Additional column options.</param> | ||
public DynamicCheckBoxColumn(object? header, | ||
Expression<Func<TModel, bool?>> getter, | ||
Action<TModel, bool?>? setter = null, | ||
GridLength? width = null, | ||
CheckBoxColumnOptions<TModel>? options = null) : base(header, getter, setter, width, | ||
options ?? new CheckBoxColumnOptions<TModel>()) { } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using Avalonia.Controls; | ||
using Avalonia.Controls.Models.TreeDataGrid; | ||
using Avalonia.Controls.Templates; | ||
|
||
namespace DynamicTreeDataGrid.Columns; | ||
|
||
public class DynamicTemplateColumn<TModel> : TemplateColumn<TModel> { | ||
public DynamicTemplateColumn(object? header, | ||
IDataTemplate cellTemplate, | ||
IDataTemplate? cellEditingTemplate = null, | ||
GridLength? width = null, | ||
TemplateColumnOptions<TModel>? options = null) : base(header, cellTemplate, | ||
cellEditingTemplate, width, options) { } | ||
|
||
public DynamicTemplateColumn(object? header, | ||
object cellTemplateResourceKey, | ||
object? cellEditingTemplateResourceKey = null, | ||
GridLength? width = null, | ||
TemplateColumnOptions<TModel>? options = null) : base(header, cellTemplateResourceKey, | ||
cellEditingTemplateResourceKey, width, options) { } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using System.Linq.Expressions; | ||
|
||
using Avalonia.Controls; | ||
using Avalonia.Controls.Models.TreeDataGrid; | ||
|
||
namespace DynamicTreeDataGrid.Columns; | ||
|
||
public class DynamicTextColumn<TModel, TValue> : TextColumn<TModel, TValue> | ||
where TModel : class { | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="TextColumn{TModel, TValue}"/> class. | ||
/// </summary> | ||
/// <param name="header">The column header.</param> | ||
/// <param name="getter"> | ||
/// An expression which given a row model, returns a cell value for the column. | ||
/// </param> | ||
/// <param name="width"> | ||
/// The column width. If null defaults to <see cref="GridLength.Auto"/>. | ||
/// </param> | ||
/// <param name="options">Additional column options.</param> | ||
public DynamicTextColumn(object? header, | ||
Expression<Func<TModel, TValue?>> getter, | ||
GridLength? width = null, | ||
TextColumnOptions<TModel>? options = null) : base(header, getter, width, options) { } | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="TextColumn{TModel, TValue}"/> class. | ||
/// </summary> | ||
/// <param name="header">The column header.</param> | ||
/// <param name="getter"> | ||
/// An expression which given a row model, returns a cell value for the column. | ||
/// </param> | ||
/// <param name="setter"> | ||
/// A method which given a row model and a cell value, writes the cell value to the | ||
/// row model. | ||
/// </param> | ||
/// <param name="width"> | ||
/// The column width. If null defaults to <see cref="GridLength.Auto"/>. | ||
/// </param> | ||
/// <param name="options">Additional column options.</param> | ||
public DynamicTextColumn(object? header, | ||
Expression<Func<TModel, TValue?>> getter, | ||
Action<TModel, TValue?> setter, | ||
GridLength? width = null, | ||
TextColumnOptions<TModel>? options = null) : base(header, getter, setter, width, | ||
options ?? new()) { } | ||
} |