|
4 | 4 | using Microsoft.UI;
|
5 | 5 | using Microsoft.UI.Xaml;
|
6 | 6 | using Microsoft.UI.Xaml.Controls;
|
| 7 | +using Microsoft.UI.Xaml.Controls.Primitives; |
7 | 8 | using Microsoft.UI.Xaml.Data;
|
8 | 9 | using Microsoft.UI.Xaml.Hosting;
|
9 | 10 | using Microsoft.UI.Xaml.Input;
|
@@ -55,6 +56,8 @@ private void OnLoaded(object sender, RoutedEventArgs e)
|
55 | 56 | itemsPanelVisual.Clip = contentClip;
|
56 | 57 | contentClip.TopInset = (float)Math.Max(-scrollViewer.VerticalOffset, 0);
|
57 | 58 | contentClip.StartAnimation("TopInset", expressionClipAnimation);
|
| 59 | + |
| 60 | + UpdateVerticalScrollBarMargin(); |
58 | 61 | }
|
59 | 62 |
|
60 | 63 | private bool Filter(object obj)
|
@@ -344,6 +347,11 @@ private static void OnItemsSourceChanged(DependencyObject d, DependencyPropertyC
|
344 | 347 | }
|
345 | 348 | }
|
346 | 349 |
|
| 350 | + private static void OnHeaderRowHeightChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) |
| 351 | + { |
| 352 | + (d as TableView)?.UpdateVerticalScrollBarMargin(); |
| 353 | + } |
| 354 | + |
347 | 355 | private static void OnAutoGenerateColumnsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
348 | 356 | {
|
349 | 357 | if (d is TableView tableView)
|
@@ -375,6 +383,18 @@ private static void OnCanFilterColumnsChanged(DependencyObject d, DependencyProp
|
375 | 383 | }
|
376 | 384 | }
|
377 | 385 |
|
| 386 | + private void UpdateVerticalScrollBarMargin() |
| 387 | + { |
| 388 | + if (GetTemplateChild("ScrollViewer") is ScrollViewer scrollViewer) |
| 389 | + { |
| 390 | + var verticalScrollBar = scrollViewer.FindDescendant<ScrollBar>(x => x.Name == "VerticalScrollBar"); |
| 391 | + if (verticalScrollBar is not null) |
| 392 | + { |
| 393 | + verticalScrollBar.Margin = new Thickness(0, HeaderRowHeight, 0, 0); |
| 394 | + } |
| 395 | + } |
| 396 | + } |
| 397 | + |
378 | 398 | internal void ClearSorting()
|
379 | 399 | {
|
380 | 400 | CollectionView.SortDescriptions.Clear();
|
@@ -480,7 +500,7 @@ public bool CanFilterColumns
|
480 | 500 |
|
481 | 501 | public static readonly new DependencyProperty ItemsSourceProperty = DependencyProperty.Register(nameof(ItemsSource), typeof(IList), typeof(TableView), new PropertyMetadata(null, OnItemsSourceChanged));
|
482 | 502 | public static readonly DependencyProperty ColumnsProperty = DependencyProperty.Register(nameof(Columns), typeof(TableViewColumnsCollection), typeof(TableView), new PropertyMetadata(null));
|
483 |
| - public static readonly DependencyProperty HeaderRowHeightProperty = DependencyProperty.Register(nameof(HeaderRowHeight), typeof(double), typeof(TableView), new PropertyMetadata(32d)); |
| 503 | + public static readonly DependencyProperty HeaderRowHeightProperty = DependencyProperty.Register(nameof(HeaderRowHeight), typeof(double), typeof(TableView), new PropertyMetadata(32d, OnHeaderRowHeightChanged)); |
484 | 504 | public static readonly DependencyProperty RowHeightProperty = DependencyProperty.Register(nameof(RowHeight), typeof(double), typeof(TableView), new PropertyMetadata(40d));
|
485 | 505 | public static readonly DependencyProperty RowMaxHeightProperty = DependencyProperty.Register(nameof(RowMaxHeight), typeof(double), typeof(TableView), new PropertyMetadata(double.PositiveInfinity));
|
486 | 506 | public static readonly DependencyProperty ShowExportOptionsProperty = DependencyProperty.Register(nameof(ShowExportOptions), typeof(bool), typeof(TableView), new PropertyMetadata(false));
|
|
0 commit comments