Skip to content

Commit e2db713

Browse files
committed
bring back alternate row colors for uno
1 parent 4c7a3f0 commit e2db713

File tree

3 files changed

+13
-25
lines changed

3 files changed

+13
-25
lines changed

src/TableView.Properties.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ public partial class TableView
125125
/// </summary>
126126
public static readonly DependencyProperty VerticalGridLinesStrokeProperty = DependencyProperty.Register(nameof(VerticalGridLinesStroke), typeof(Brush), typeof(TableView), new PropertyMetadata(default, OnGridLinesPropertyChanged));
127127

128-
#if WINDOWS
129128
/// <summary>
130129
/// Identifies the AlternateRowForeground dependency property.
131130
/// </summary>
@@ -136,6 +135,7 @@ public partial class TableView
136135
/// </summary>
137136
public static readonly DependencyProperty AlternateRowBackgroundProperty = DependencyProperty.Register(nameof(AlternateRowBackground), typeof(Brush), typeof(TableView), new PropertyMetadata(null, OnAlternateRowColorChanged));
138137

138+
#if WINDOWS
139139
/// <summary>
140140
/// Identifies the RowContextFlyout dependency property.
141141
/// </summary>
@@ -431,7 +431,6 @@ public Brush HorizontalGridLinesStroke
431431
set => SetValue(HorizontalGridLinesStrokeProperty, value);
432432
}
433433

434-
#if WINDOWS
435434
/// <summary>
436435
/// Gets or sets the background brush for alternate rows.
437436
/// </summary>
@@ -450,6 +449,7 @@ public Brush AlternateRowForeground
450449
set => SetValue(AlternateRowForegroundProperty, value);
451450
}
452451

452+
#if WINDOWS
453453
/// <summary>
454454
/// Gets or sets the context flyout for rows.
455455
/// </summary>

src/TableView.cs

-2
Original file line numberDiff line numberDiff line change
@@ -1303,15 +1303,13 @@ private void EnsureGridLines()
13031303
/// </summary>
13041304
internal void EnsureAlternateRowColors()
13051305
{
1306-
#if WINDOWS
13071306
DispatcherQueue.TryEnqueue(() =>
13081307
{
13091308
foreach (var row in _rows)
13101309
{
13111310
row.EnsureAlternateColors();
13121311
}
13131312
});
1314-
#endif
13151313
}
13161314

13171315
/// <summary>

src/TableViewRow.cs

+11-21
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,9 @@ public partial class TableViewRow : ListViewItem
2626
private ListViewItemPresenter? _itemPresenter;
2727
private TableViewCellsPresenter? _cellPresenter;
2828
private Border? _selectionBackground;
29-
#if WINDOWS
3029
private bool _ensureCells = true;
3130
private Brush? _cellPresenterBackground;
32-
private Brush? _cellPresenterForeground;
33-
#endif
31+
private Brush? _cellPresenterForeground;
3432

3533
/// <summary>
3634
/// Initializes a new instance of the TableViewRow class.
@@ -121,21 +119,17 @@ protected override void OnIsSelectedChanged()
121119
/// </summary>
122120
private void OnForegroundChanged()
123121
{
124-
#if WINDOWS
125122
_cellPresenterForeground = Foreground;
126-
EnsureAlternateColors();
127-
#endif
123+
EnsureAlternateColors();
128124
}
129125

130126
/// <summary>
131127
/// Handles the Background property changed.
132128
/// </summary>
133129
private void OnBackgroundChanged()
134130
{
135-
#if WINDOWS
136131
_cellPresenterBackground = Background;
137-
EnsureAlternateColors();
138-
#endif
132+
EnsureAlternateColors();
139133
}
140134

141135
/// <summary>
@@ -153,10 +147,8 @@ protected override void OnApplyTemplate()
153147
{
154148
base.OnApplyTemplate();
155149

156-
#if WINDOWS
157150
_cellPresenterBackground = Background;
158-
_cellPresenterForeground = Foreground;
159-
#endif
151+
_cellPresenterForeground = Foreground;
160152
_itemPresenter = GetTemplateChild("Root") as ListViewItemPresenter;
161153

162154
if (_itemPresenter is not null)
@@ -184,10 +176,10 @@ protected override void OnContentChanged(object oldContent, object newContent)
184176
else
185177
{
186178
#endif
187-
foreach (var cell in Cells)
188-
{
189-
cell.RefreshElement();
190-
}
179+
foreach (var cell in Cells)
180+
{
181+
cell.RefreshElement();
182+
}
191183
#if WINDOWS
192184
}
193185
#endif
@@ -243,8 +235,8 @@ internal void EnsureCells()
243235
CellPresenter.Children.Clear();
244236

245237
AddCells(TableView.Columns.VisibleColumns);
246-
_ensureCells = false;
247-
}
238+
_ensureCells = false;
239+
}
248240
}
249241

250242
/// <summary>
@@ -516,7 +508,6 @@ internal void EnsureLayout()
516508
}
517509
}
518510

519-
#if WINDOWS
520511
/// <summary>
521512
/// Ensures alternate colors are applied to the row.
522513
/// </summary>
@@ -529,8 +520,7 @@ internal void EnsureAlternateColors()
529520

530521
CellPresenter.Foreground =
531522
Index % 2 == 1 && TableView.AlternateRowForeground is not null ? TableView.AlternateRowForeground : _cellPresenterForeground;
532-
}
533-
#endif
523+
}
534524

535525
/// <summary>
536526
/// Gets the list of cells in the row.

0 commit comments

Comments
 (0)