Skip to content

Commit 70694a9

Browse files
committed
added HeaderRowMin & Max properties
1 parent 50180e7 commit 70694a9

File tree

5 files changed

+36
-8
lines changed

5 files changed

+36
-8
lines changed

src/TableView.Properties.cs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,17 @@ public partial class TableView
2828
/// <summary>
2929
/// Identifies the HeaderRowHeight dependency property.
3030
/// </summary>
31-
public static readonly DependencyProperty HeaderRowHeightProperty = DependencyProperty.Register(nameof(HeaderRowHeight), typeof(double), typeof(TableView), new PropertyMetadata(32d, OnHeaderRowHeightChanged));
31+
public static readonly DependencyProperty HeaderRowHeightProperty = DependencyProperty.Register(nameof(HeaderRowHeight), typeof(double), typeof(TableView), new PropertyMetadata(double.NaN, OnHeaderRowHeightChanged));
32+
33+
/// <summary>
34+
/// Identifies the HeaderRowMaxHeight dependency property.
35+
/// </summary>
36+
public static readonly DependencyProperty HeaderRowMaxHeightProperty = DependencyProperty.Register(nameof(HeaderRowMaxHeight), typeof(double), typeof(TableView), new PropertyMetadata(double.PositiveInfinity, OnHeaderRowHeightChanged));
37+
38+
/// <summary>
39+
/// Identifies the HeaderRowMinHeight dependency property.
40+
/// </summary>
41+
public static readonly DependencyProperty HeaderRowMinHeightProperty = DependencyProperty.Register(nameof(HeaderRowMinHeight), typeof(double), typeof(TableView), new PropertyMetadata(32d, OnHeaderRowHeightChanged));
3242

3343
/// <summary>
3444
/// Identifies the RowHeight dependency property.
@@ -252,6 +262,24 @@ public double HeaderRowHeight
252262
set => SetValue(HeaderRowHeightProperty, value);
253263
}
254264

265+
/// <summary>
266+
/// Gets or sets the max height of the header row.
267+
/// </summary>
268+
public double HeaderRowMaxHeight
269+
{
270+
get => (double)GetValue(HeaderRowMaxHeightProperty);
271+
set => SetValue(HeaderRowMaxHeightProperty, value);
272+
}
273+
274+
/// <summary>
275+
/// Gets or sets the min height of the header row.
276+
/// </summary>
277+
public double HeaderRowMinHeight
278+
{
279+
get => (double)GetValue(HeaderRowMinHeightProperty);
280+
set => SetValue(HeaderRowMinHeightProperty, value);
281+
}
282+
255283
/// <summary>
256284
/// Gets or sets the height of the rows.
257285
/// </summary>

src/TableView.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ private void UpdateVerticalScrollBarMargin()
735735
var verticalScrollBar = scrollViewer.FindDescendant<ScrollBar>(x => x.Name == "VerticalScrollBar");
736736
if (verticalScrollBar is not null)
737737
{
738-
verticalScrollBar.Margin = new Thickness(0, HeaderRowHeight, 0, 0);
738+
verticalScrollBar.Margin = new Thickness(0, _headerRow?.ActualHeight ?? 0, 0, 0);
739739
}
740740
}
741741
}
@@ -1364,7 +1364,7 @@ internal bool ShowRowContext(TableViewRow row, Point position)
13641364
RowContextFlyout.ShowAt(row, new FlyoutShowOptions
13651365
{
13661366
#if WINDOWS
1367-
ShowMode = FlyoutShowMode.Standard,
1367+
ShowMode = FlyoutShowMode.Standard,
13681368
#endif
13691369
Placement = RowContextFlyout.Placement,
13701370
Position = position
@@ -1389,7 +1389,7 @@ internal bool ShowCellContext(TableViewCell cell, Point position)
13891389
CellContextFlyout.ShowAt(cell, new FlyoutShowOptions
13901390
{
13911391
#if WINDOWS
1392-
ShowMode = FlyoutShowMode.Standard,
1392+
ShowMode = FlyoutShowMode.Standard,
13931393
#endif
13941394
Placement = CellContextFlyout.Placement,
13951395
Position = position

src/TableViewHeaderRow.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ internal void CalculateHeaderWidths()
224224
var autoColumns = allColumns.Where(x => x.Width.IsAuto).ToList();
225225
var absoluteColumns = allColumns.Where(x => x.Width.IsAbsolute).ToList();
226226

227-
var height = TableView.HeaderRowHeight;
227+
var height = ActualHeight;
228228
var availableWidth = TableView.ActualWidth - 32;
229229
var starUnitWeight = starColumns.Select(x => x.Width.Value).Sum();
230230
var fixedWidth = autoColumns.Select(x =>
@@ -294,7 +294,7 @@ internal void CalculateHeaderWidths()
294294
DispatcherQueue.TryEnqueue(() =>
295295
header.Measure(
296296
new Size(header.Width,
297-
_headersStackPanel?.ActualHeight ?? TableView.HeaderRowHeight)));
297+
_headersStackPanel?.ActualHeight ?? ActualHeight)));
298298
}
299299
}
300300

src/Themes/TableView.xaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@
103103
<local:TableViewHeaderRow x:Name="HeaderRow"
104104
IsTabStop="False"
105105
Height="{TemplateBinding HeaderRowHeight}"
106+
MaxHeight="{TemplateBinding HeaderRowMaxHeight}"
107+
MinHeight="{TemplateBinding HeaderRowMinHeight}"
106108
TableView="{Binding RelativeSource={RelativeSource TemplatedParent}}">
107109
<interactivity:Interaction.Behaviors>
108110
<behaviors:StickyHeaderBehavior />

src/Themes/TableViewHeaderRow.xaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
<Style x:Key="DefaultTableViewHeaderRowStyle"
1010
TargetType="local:TableViewHeaderRow">
11-
<Setter Property="Height"
12-
Value="32" />
1311
<Setter Property="Background"
1412
Value="{ThemeResource TableViewHeaderRowBackground}" />
1513
<Setter Property="Template">

0 commit comments

Comments
 (0)