Skip to content

Commit 2fa146d

Browse files
committed
use _cellStyles for caching conditional cell styles
1 parent 52c0f11 commit 2fa146d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/TableViewCell.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public partial class TableViewCell : ContentControl
3232
private Rectangle? _v_gridLine;
3333
private object? _uneditedValue;
3434
private RoutedEventArgs? _editingArgs;
35+
private IList<TableViewConditionalCellStyle>? _cellStyles;
3536

3637
/// <summary>
3738
/// Initializes a new instance of the TableViewCell class.
@@ -537,11 +538,11 @@ internal void EnsureGridLines()
537538
/// <param name="item">The data item associated with the cell.</param>
538539
internal void EnsureStyle(object? item)
539540
{
540-
IList<TableViewConditionalCellStyle> cellStyles = [
541+
_cellStyles ??= [
541542
.. Column?.ConditionalCellStyles ?? [], // Column styles have first priority
542543
.. TableView?.ConditionalCellStyles ?? []]; // TableView styles have second priority
543544

544-
Style = cellStyles.FirstOrDefault(c => c.Predicate?.Invoke(new(Column!, item)) is true)?
545+
Style = _cellStyles.FirstOrDefault(c => c.Predicate?.Invoke(new(Column!, item)) is true)?
545546
.Style ?? Column?.CellStyle ?? TableView?.CellStyle;
546547
}
547548

0 commit comments

Comments
 (0)