-
Notifications
You must be signed in to change notification settings - Fork 57
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
Edward Miller
committed
Jan 17, 2024
1 parent
6c2f084
commit 200ca0c
Showing
10 changed files
with
157 additions
and
115 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
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
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
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
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
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
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
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,55 @@ | ||
namespace Maui.DataGrid; | ||
|
||
using Microsoft.Maui.Controls; | ||
|
||
/// <summary> | ||
/// Specifies each cell of the DataGrid. | ||
/// </summary> | ||
internal sealed class DataGridCell : Grid | ||
{ | ||
internal DataGridCell(View cellContent, Color? backgroundColor) | ||
{ | ||
var colorfulCellContent = new ContentView | ||
{ | ||
BackgroundColor = backgroundColor, | ||
Content = cellContent, | ||
}; | ||
|
||
Children.Add(colorfulCellContent); | ||
} | ||
|
||
internal void UpdateBindings(DataGrid dataGrid, bool bordersVisible = true) | ||
{ | ||
// The DataGridCell is a grid, and the padding constitutes the cell's border | ||
// And the Background constitutes the border color of the cell. | ||
|
||
if (bordersVisible) | ||
{ | ||
BackgroundColor = dataGrid.BorderColor; | ||
Padding = dataGrid.BorderThickness; | ||
|
||
SetBinding(BackgroundColorProperty, new Binding(nameof(DataGrid.BorderColor), source: dataGrid)); | ||
SetBinding(PaddingProperty, new Binding(nameof(DataGrid.BorderThickness), source: dataGrid)); | ||
} | ||
else | ||
{ | ||
Padding = 0; | ||
|
||
RemoveBinding(BackgroundColorProperty); | ||
RemoveBinding(PaddingProperty); | ||
} | ||
} | ||
|
||
internal void UpdateCellColors(Color? bgColor, Color? textColor = null) | ||
{ | ||
foreach (var cellContent in Children.OfType<ContentView>()) | ||
{ | ||
cellContent.BackgroundColor = bgColor; | ||
|
||
if (cellContent.Content is Label label && textColor != null) | ||
{ | ||
label.TextColor = textColor; | ||
} | ||
} | ||
} | ||
} |
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
Oops, something went wrong.