Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/Columns/TableViewCheckBoxColumn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ namespace WinUI.TableView;
/// Represents a column in a TableView that displays a CheckBox.
/// </summary>
[StyleTypedProperty(Property = nameof(ElementStyle), StyleTargetType = typeof(CheckBox))]
#if WINDOWS
[WinRT.GeneratedBindableCustomProperty]
#endif
public partial class TableViewCheckBoxColumn : TableViewBoundColumn
{
/// <summary>
Expand Down
13 changes: 12 additions & 1 deletion src/Columns/TableViewColumn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,17 @@ tableView.CurrentCellSlot is not null &&
}
}

/// <summary>
/// Handles changes to the Header property.
/// </summary>
private static void OnHeaderChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is TableViewColumn column && column.HeaderControl is not null)
{
column.HeaderControl.Content = e.NewValue;
Comment on lines +570 to +572
}
}

/// <summary>
/// Handles changes to the CanFilter property.
/// </summary>
Expand Down Expand Up @@ -622,7 +633,7 @@ public string? SortMemberPath
/// <summary>
/// Identifies the Header dependency property.
/// </summary>
public static readonly DependencyProperty HeaderProperty = DependencyProperty.Register(nameof(Header), typeof(object), typeof(TableViewColumn), new PropertyMetadata(null));
public static readonly DependencyProperty HeaderProperty = DependencyProperty.Register(nameof(Header), typeof(object), typeof(TableViewColumn), new PropertyMetadata(null, OnHeaderChanged));

/// <summary>
/// Identifies the Width dependency property.
Expand Down
16 changes: 8 additions & 8 deletions src/Columns/TableViewComboBoxColumn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ namespace WinUI.TableView;
/// </summary>
[StyleTypedProperty(Property = nameof(ElementStyle), StyleTargetType = typeof(TextBlock))]
[StyleTypedProperty(Property = nameof(EditingElementStyle), StyleTargetType = typeof(ComboBox))]
#if WINDOWS
[WinRT.GeneratedBindableCustomProperty]
#endif
public partial class TableViewComboBoxColumn : TableViewBoundColumn
{
/// <summary>
Expand Down Expand Up @@ -49,12 +46,15 @@ public override FrameworkElement GenerateElement(TableViewCell cell, object? dat
/// <returns>A ComboBox element.</returns>
public override FrameworkElement GenerateEditingElement(TableViewCell cell, object? dataItem)
{
var comboBox = new ComboBox { HorizontalAlignment = HorizontalAlignment.Stretch };
comboBox.SetBinding(ItemsControl.ItemsSourceProperty, new Binding { Source = this, Path = new PropertyPath(nameof(ItemsSource)) });
comboBox.SetBinding(Selector.SelectedValuePathProperty, new Binding { Source = this, Path = new PropertyPath(nameof(SelectedValuePath)) });
comboBox.SetBinding(ItemsControl.DisplayMemberPathProperty, new Binding { Source = this, Path = new PropertyPath(nameof(DisplayMemberPath)) });
var comboBox = new ComboBox
{
HorizontalAlignment = HorizontalAlignment.Stretch,
ItemsSource = ItemsSource,
SelectedValuePath = SelectedValuePath,
DisplayMemberPath = DisplayMemberPath,
IsEditable = IsEditable
};
comboBox.SetBinding(Selector.SelectedItemProperty, Binding);
comboBox.SetBinding(ComboBox.IsEditableProperty, new Binding { Source = this, Path = new PropertyPath(nameof(IsEditable)) });

if (TextBinding is not null)
{
Expand Down
31 changes: 22 additions & 9 deletions src/Columns/TableViewDateColumn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
/// </summary>
[StyleTypedProperty(Property = nameof(ElementStyle), StyleTargetType = typeof(TextBlock))]
[StyleTypedProperty(Property = nameof(EditingElementStyle), StyleTargetType = typeof(TableViewDatePicker))]
#if WINDOWS
[WinRT.GeneratedBindableCustomProperty]
#endif
public partial class TableViewDateColumn : TableViewBoundColumn
{
/// <summary>
Expand Down Expand Up @@ -48,16 +45,21 @@
Margin = new Thickness(12, 0, 12, 0),
};

textBlock.SetValue(DateTimeFormatHelper.FormatProperty, DateFormat);
textBlock.SetBinding(DateTimeFormatHelper.ValueProperty, Binding);
textBlock.SetBinding(DateTimeFormatHelper.FormatProperty, new Binding
{
Path = new PropertyPath(nameof(DateFormat)),
Source = this
});

return textBlock;
}

/// <inheritdoc/>
public override void RefreshElement(TableViewCell cell, object? dataItem)
{
if (cell.Content is TextBlock textBlock)
{
textBlock.SetValue(DateTimeFormatHelper.FormatProperty, DateFormat);
}
}

/// <summary>
/// Generates a TableViewDatePicker element for editing the cell.
/// </summary>
Expand Down Expand Up @@ -123,7 +125,7 @@

if (!string.IsNullOrEmpty(PropertyPath))
{
var propertyInfo = type.GetProperty(PropertyPath);

Check warning on line 128 in src/Columns/TableViewDateColumn.cs

View workflow job for this annotation

GitHub Actions / build-uno-wasm

'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties' in call to 'System.Type.GetProperty(String)'. The return value of method 'System.Object.GetType()' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
if (propertyInfo is not null)
{
type = propertyInfo.PropertyType;
Expand Down Expand Up @@ -263,5 +265,16 @@
/// <summary>
/// Identifies the DateFormat dependency property.
/// </summary>
public static readonly DependencyProperty DateFormatProperty = DependencyProperty.Register(nameof(DateFormat), typeof(string), typeof(TableViewDateColumn), new PropertyMetadata("shortdate"));
public static readonly DependencyProperty DateFormatProperty = DependencyProperty.Register(nameof(DateFormat), typeof(string), typeof(TableViewDateColumn), new PropertyMetadata("shortdate", OnDateFormatChanged));

/// <summary>
/// Handles changes to the DateFormat property.
/// </summary>
private static void OnDateFormatChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is TableViewDateColumn column)
{
column.OwningCollection?.HandleColumnPropertyChanged(column, nameof(DateFormat));
}
}
}
3 changes: 0 additions & 3 deletions src/Columns/TableViewHyperlinkColumn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ namespace WinUI.TableView;
/// </summary>
[StyleTypedProperty(Property = nameof(ElementStyle), StyleTargetType = typeof(HyperlinkButton))]
[StyleTypedProperty(Property = nameof(EditingElementStyle), StyleTargetType = typeof(TextBox))]
#if WINDOWS
[WinRT.GeneratedBindableCustomProperty]
#endif
public partial class TableViewHyperlinkColumn : TableViewTextColumn
{
/// <summary>
Expand Down
3 changes: 0 additions & 3 deletions src/Columns/TableViewNumberColumn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ namespace WinUI.TableView;
/// </summary>
[StyleTypedProperty(Property = nameof(ElementStyle), StyleTargetType = typeof(TextBlock))]
[StyleTypedProperty(Property = nameof(EditingElementStyle), StyleTargetType = typeof(NumberBox))]
#if WINDOWS
[WinRT.GeneratedBindableCustomProperty]
#endif
public partial class TableViewNumberColumn : TableViewBoundColumn
{
/// <summary>
Expand Down
3 changes: 0 additions & 3 deletions src/Columns/TableViewTemplateColumn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ namespace WinUI.TableView;
/// <summary>
/// Represents a column in a TableView that uses a DataTemplate for its content.
/// </summary>
#if WINDOWS
[WinRT.GeneratedBindableCustomProperty]
#endif
[ContentProperty(Name = nameof(CellTemplate))]
public partial class TableViewTemplateColumn : TableViewColumn
{
Expand Down
3 changes: 0 additions & 3 deletions src/Columns/TableViewTextColumn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ namespace WinUI.TableView;
/// </summary>
[StyleTypedProperty(Property = nameof(ElementStyle), StyleTargetType = typeof(TextBlock))]
[StyleTypedProperty(Property = nameof(EditingElementStyle), StyleTargetType = typeof(TextBox))]
#if WINDOWS
[WinRT.GeneratedBindableCustomProperty]
#endif
public partial class TableViewTextColumn : TableViewBoundColumn
{
/// <summary>
Expand Down
31 changes: 22 additions & 9 deletions src/Columns/TableViewTimeColumn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
/// </summary>
[StyleTypedProperty(Property = nameof(ElementStyle), StyleTargetType = typeof(TextBlock))]
[StyleTypedProperty(Property = nameof(EditingElementStyle), StyleTargetType = typeof(TableViewTimePicker))]
#if WINDOWS
[WinRT.GeneratedBindableCustomProperty]
#endif
public partial class TableViewTimeColumn : TableViewBoundColumn
{
/// <summary>
Expand Down Expand Up @@ -44,16 +41,21 @@
Margin = new Thickness(12, 0, 12, 0),
};

textBlock.SetValue(DateTimeFormatHelper.FormatProperty, ClockIdentifier);
textBlock.SetBinding(DateTimeFormatHelper.ValueProperty, Binding);
textBlock.SetBinding(DateTimeFormatHelper.FormatProperty, new Binding
{
Path = new PropertyPath(nameof(ClockIdentifier)),
Source = this
});

return textBlock;
}

/// <inheritdoc/>
public override void RefreshElement(TableViewCell cell, object? dataItem)
{
if (cell.Content is TextBlock textBlock)
{
textBlock.SetValue(DateTimeFormatHelper.FormatProperty, ClockIdentifier);
}
}

/// <summary>
/// Generates a TableViewTimePicker element for editing the cell.
/// </summary>
Expand Down Expand Up @@ -114,7 +116,7 @@

if (!string.IsNullOrEmpty(PropertyPath))
{
var propertyInfo = type.GetProperty(PropertyPath);

Check warning on line 119 in src/Columns/TableViewTimeColumn.cs

View workflow job for this annotation

GitHub Actions / build-uno-wasm

'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties' in call to 'System.Type.GetProperty(String)'. The return value of method 'System.Object.GetType()' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
if (propertyInfo is not null)
{
type = propertyInfo.PropertyType;
Expand Down Expand Up @@ -165,7 +167,18 @@
/// <summary>
/// Identifies the ClockIdentifier dependency property.
/// </summary>
public static readonly DependencyProperty ClockIdentifierProperty = DependencyProperty.Register(nameof(ClockIdentifier), typeof(string), typeof(TableViewTimeColumn), new PropertyMetadata(default));
public static readonly DependencyProperty ClockIdentifierProperty = DependencyProperty.Register(nameof(ClockIdentifier), typeof(string), typeof(TableViewTimeColumn), new PropertyMetadata(default, OnClockIdentifierChanged));

/// <summary>
/// Handles changes to the ClockIdentifier property.
/// </summary>
private static void OnClockIdentifierChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is TableViewTimeColumn column)
{
column.OwningCollection?.HandleColumnPropertyChanged(column, nameof(ClockIdentifier));
}
}

/// <summary>
/// Identifies the PlaceholderText dependency property.
Expand Down
3 changes: 0 additions & 3 deletions src/Columns/TableViewToggleSwitchColumn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ namespace WinUI.TableView;
/// Represents a column in a TableView that displays a ToggleSwitch.
/// </summary>
[StyleTypedProperty(Property = nameof(ElementStyle), StyleTargetType = typeof(ToggleSwitch))]
#if WINDOWS
[WinRT.GeneratedBindableCustomProperty]
#endif
public partial class TableViewToggleSwitchColumn : TableViewBoundColumn
{
/// <summary>
Expand Down
24 changes: 20 additions & 4 deletions src/ItemsSource/TableViewGroupInfo.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#if WINDOWS
using Microsoft.UI.Xaml;
using WinRT;

namespace WinUI.TableView;

Expand All @@ -9,7 +8,6 @@ namespace WinUI.TableView;
/// count, nesting level, and expanded/collapsed state. This is the object bound as a <see cref="CollectionViewGroup"/>'s
/// <see cref="CollectionViewGroup.Group"/>.
/// </summary>
[GeneratedBindableCustomProperty]
public partial class TableViewGroupInfo : DependencyObject
{

Expand Down Expand Up @@ -40,12 +38,20 @@ private static void OnIsExpandedChanged(DependencyObject d, DependencyPropertyCh
/// <summary>
/// Gets the group's key, e.g. the value of the column/property being grouped by.
/// </summary>
public object? Key { get; init; }
public object? Key
{
get => GetValue(KeyProperty);
init => SetValue(KeyProperty, value);
}

/// <summary>
/// Gets the number of items in this group (including all descendant subgroups/items, if any).
/// </summary>
public int Count { get; init; }
public int Count
{
get => (int)GetValue(CountProperty);
init => SetValue(CountProperty, value);
}

/// <summary>
/// Gets the zero-based nesting level of this group among the active <see cref="GroupDescription"/> entries.
Expand All @@ -62,6 +68,16 @@ public bool IsExpanded
set => SetValue(IsExpandedProperty, value);
}

/// <summary>
/// Identifies the <see cref="Key"/> dependency property.
/// </summary>
public static readonly DependencyProperty KeyProperty = DependencyProperty.Register(nameof(Key), typeof(object), typeof(TableViewGroupInfo), new PropertyMetadata(null));

/// <summary>
/// Identifies the <see cref="Count"/> dependency property.
/// </summary>
public static readonly DependencyProperty CountProperty = DependencyProperty.Register(nameof(Count), typeof(int), typeof(TableViewGroupInfo), new PropertyMetadata(0));

/// <summary>
/// Identifies the <see cref="IsExpanded"/> dependency property.
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions src/TableView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,8 @@
var row = new TableViewRow { TableView = this };

// Set bindings for FontFamily and FontSize to propagate from TableView to TableViewRow
row.SetBinding(FontFamilyProperty, new Binding { Path = new("TableView.FontFamily"), RelativeSource = new() { Mode = RelativeSourceMode.Self } });
row.SetBinding(FontSizeProperty, new Binding { Path = new("TableView.FontSize"), RelativeSource = new() { Mode = RelativeSourceMode.Self } });
row.SetBinding(FontFamilyProperty, new Binding { Path = new(nameof(FontFamily)), Source = this });
row.SetBinding(FontSizeProperty, new Binding { Path = new(nameof(FontSize)), Source = this });

_rows.Add(row);
return row;
Expand Down Expand Up @@ -1119,7 +1119,7 @@
#if WINDOWS
/// <summary>
/// Applies <see cref="AreStickyGroupHeadersEnabled"/> to the underlying <see cref="ItemsStackPanel"/>, if the
/// current <see cref="ItemsPanelRoot"/> is one.

Check warning on line 1122 in src/TableView.cs

View workflow job for this annotation

GitHub Actions / build-winui-sample (x64)

XML comment has cref attribute 'ItemsPanelRoot' that could not be resolved

Check warning on line 1122 in src/TableView.cs

View workflow job for this annotation

GitHub Actions / build-winui-sample (x64)

XML comment has cref attribute 'ItemsPanelRoot' that could not be resolved

Check warning on line 1122 in src/TableView.cs

View workflow job for this annotation

GitHub Actions / build-winui-sample (x86)

XML comment has cref attribute 'ItemsPanelRoot' that could not be resolved

Check warning on line 1122 in src/TableView.cs

View workflow job for this annotation

GitHub Actions / build-winui-sample (x86)

XML comment has cref attribute 'ItemsPanelRoot' that could not be resolved

Check warning on line 1122 in src/TableView.cs

View workflow job for this annotation

GitHub Actions / build-winui-sample (ARM64)

XML comment has cref attribute 'ItemsPanelRoot' that could not be resolved

Check warning on line 1122 in src/TableView.cs

View workflow job for this annotation

GitHub Actions / build-winui-sample (ARM64)

XML comment has cref attribute 'ItemsPanelRoot' that could not be resolved

Check warning on line 1122 in src/TableView.cs

View workflow job for this annotation

GitHub Actions / build

XML comment has cref attribute 'ItemsPanelRoot' that could not be resolved

Check warning on line 1122 in src/TableView.cs

View workflow job for this annotation

GitHub Actions / build

XML comment has cref attribute 'ItemsPanelRoot' that could not be resolved

Check warning on line 1122 in src/TableView.cs

View workflow job for this annotation

GitHub Actions / build

XML comment has cref attribute 'ItemsPanelRoot' that could not be resolved

Check warning on line 1122 in src/TableView.cs

View workflow job for this annotation

GitHub Actions / build

XML comment has cref attribute 'ItemsPanelRoot' that could not be resolved
/// </summary>
private void ApplyStickyGroupHeadersSetting()
{
Expand Down
3 changes: 0 additions & 3 deletions src/TableViewCell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
[TemplateVisualState(Name = VisualStates.StateCurrent, GroupName = VisualStates.GroupCurrent)]
[TemplateVisualState(Name = VisualStates.StateSelected, GroupName = VisualStates.GroupSelection)]
[TemplateVisualState(Name = VisualStates.StateUnselected, GroupName = VisualStates.GroupSelection)]
#if WINDOWS
[WinRT.GeneratedBindableCustomProperty]
#endif
public partial class TableViewCell : ContentControl
{
private ContentPresenter? _contentPresenter;
Expand Down Expand Up @@ -234,9 +231,9 @@

/// <summary>
/// Begins a live resize-drag preview for this cell: generously (re)measures its content once so
/// widening can freely reveal more of it, and creates this cell's own <see cref="Clip"/> geometry

Check warning on line 234 in src/TableViewCell.cs

View workflow job for this annotation

GitHub Actions / build-winui-sample (x64)

XML comment has cref attribute 'Clip' that could not be resolved

Check warning on line 234 in src/TableViewCell.cs

View workflow job for this annotation

GitHub Actions / build-winui-sample (x64)

XML comment has cref attribute 'Clip' that could not be resolved

Check warning on line 234 in src/TableViewCell.cs

View workflow job for this annotation

GitHub Actions / build-winui-sample (x86)

XML comment has cref attribute 'Clip' that could not be resolved

Check warning on line 234 in src/TableViewCell.cs

View workflow job for this annotation

GitHub Actions / build-winui-sample (x86)

XML comment has cref attribute 'Clip' that could not be resolved

Check warning on line 234 in src/TableViewCell.cs

View workflow job for this annotation

GitHub Actions / build-uno-desktop

XML comment has cref attribute 'Clip' that could not be resolved

Check warning on line 234 in src/TableViewCell.cs

View workflow job for this annotation

GitHub Actions / build-winui-sample (ARM64)

XML comment has cref attribute 'Clip' that could not be resolved

Check warning on line 234 in src/TableViewCell.cs

View workflow job for this annotation

GitHub Actions / build-winui-sample (ARM64)

XML comment has cref attribute 'Clip' that could not be resolved

Check warning on line 234 in src/TableViewCell.cs

View workflow job for this annotation

GitHub Actions / build

XML comment has cref attribute 'Clip' that could not be resolved

Check warning on line 234 in src/TableViewCell.cs

View workflow job for this annotation

GitHub Actions / build

XML comment has cref attribute 'Clip' that could not be resolved

Check warning on line 234 in src/TableViewCell.cs

View workflow job for this annotation

GitHub Actions / build

XML comment has cref attribute 'Clip' that could not be resolved

Check warning on line 234 in src/TableViewCell.cs

View workflow job for this annotation

GitHub Actions / build

XML comment has cref attribute 'Clip' that could not be resolved

Check warning on line 234 in src/TableViewCell.cs

View workflow job for this annotation

GitHub Actions / build-uno-wasm

XML comment has cref attribute 'Clip' that could not be resolved
/// and gridline shift transform. These are per-cell instances (not shared across cells — WinUI
/// throws if the same <see cref="RectangleGeometry"/> is assigned as <see cref="Clip"/> on more

Check warning on line 236 in src/TableViewCell.cs

View workflow job for this annotation

GitHub Actions / build-winui-sample (x64)

XML comment has cref attribute 'Clip' that could not be resolved

Check warning on line 236 in src/TableViewCell.cs

View workflow job for this annotation

GitHub Actions / build-winui-sample (x64)

XML comment has cref attribute 'Clip' that could not be resolved

Check warning on line 236 in src/TableViewCell.cs

View workflow job for this annotation

GitHub Actions / build-winui-sample (x86)

XML comment has cref attribute 'Clip' that could not be resolved

Check warning on line 236 in src/TableViewCell.cs

View workflow job for this annotation

GitHub Actions / build-winui-sample (x86)

XML comment has cref attribute 'Clip' that could not be resolved

Check warning on line 236 in src/TableViewCell.cs

View workflow job for this annotation

GitHub Actions / build-uno-desktop

XML comment has cref attribute 'Clip' that could not be resolved

Check warning on line 236 in src/TableViewCell.cs

View workflow job for this annotation

GitHub Actions / build-winui-sample (ARM64)

XML comment has cref attribute 'Clip' that could not be resolved

Check warning on line 236 in src/TableViewCell.cs

View workflow job for this annotation

GitHub Actions / build-winui-sample (ARM64)

XML comment has cref attribute 'Clip' that could not be resolved

Check warning on line 236 in src/TableViewCell.cs

View workflow job for this annotation

GitHub Actions / build

XML comment has cref attribute 'Clip' that could not be resolved

Check warning on line 236 in src/TableViewCell.cs

View workflow job for this annotation

GitHub Actions / build

XML comment has cref attribute 'Clip' that could not be resolved

Check warning on line 236 in src/TableViewCell.cs

View workflow job for this annotation

GitHub Actions / build

XML comment has cref attribute 'Clip' that could not be resolved

Check warning on line 236 in src/TableViewCell.cs

View workflow job for this annotation

GitHub Actions / build

XML comment has cref attribute 'Clip' that could not be resolved

Check warning on line 236 in src/TableViewCell.cs

View workflow job for this annotation

GitHub Actions / build-uno-wasm

XML comment has cref attribute 'Clip' that could not be resolved
/// than one element at a time), mutated in place every frame by
/// <see cref="UpdateResizePreviewClip"/>/<see cref="UpdateGridLineShift"/> — still no Measure/Arrange
/// per frame, just not a single shared instance across every row.
Expand Down
16 changes: 13 additions & 3 deletions src/TableViewGroupHeaderRow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ public TableViewGroupHeaderRow()
/// </summary>
internal TableView? TableView { get; set; }

/// <summary>
/// Gets the <see cref="TableViewGroupInfo"/> this row is the header for.
/// </summary>
/// <remarks>
/// Exposing it here also puts <see cref="TableViewGroupInfo"/> in the XAML type metadata generated for this
/// library, which is what lets <c>{Binding Key}</c>/<c>{Binding Count}</c> in a group header template resolve
/// under trimming/Native AOT without the type needing <c>WinRT.GeneratedBindableCustomProperty</c>.
/// </remarks>
public TableViewGroupInfo? GroupInfo => Content as TableViewGroupInfo;

/// <inheritdoc/>
protected override void OnApplyTemplate()
{
Expand All @@ -52,7 +62,7 @@ protected override void OnApplyTemplate()
EnsureGridLines();
UpdateExpandCollapseButtonVisibility();

if (Content is TableViewGroupInfo groupInfo)
if (GroupInfo is { } groupInfo)
{
UpdateExpandCollapseVisualState(groupInfo.IsExpanded);
}
Expand Down Expand Up @@ -101,7 +111,7 @@ internal void UpdateExpandCollapseButtonVisibility()
/// </summary>
private void OnExpandCollapseButtonClick(object sender, RoutedEventArgs e)
{
if (Content is TableViewGroupInfo groupInfo)
if (GroupInfo is { } groupInfo)
{
groupInfo.IsExpanded = !groupInfo.IsExpanded;
UpdateExpandCollapseVisualState(groupInfo.IsExpanded);
Expand All @@ -113,7 +123,7 @@ protected override void OnContentChanged(object oldContent, object newContent)
{
base.OnContentChanged(oldContent, newContent);

if (Content is TableViewGroupInfo groupInfo)
if (GroupInfo is { } groupInfo)
{
_indentPlaceholder?.Width = groupInfo.Level * GroupIndentSize;
UpdateExpandCollapseVisualState(groupInfo.IsExpanded);
Expand Down
5 changes: 1 addition & 4 deletions src/TableViewHeaderRow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -255,13 +255,10 @@ private void AddHeaders(IEnumerable<TableViewColumn> columns)
{
foreach (var column in columns)
{
var header = new TableViewColumnHeader { DataContext = column, Column = column };
var header = new TableViewColumnHeader { DataContext = column, Column = column, Content = column.Header };
column.HeaderControl = header;

InsertHeader(header);

header.SetBinding(ContentControl.ContentProperty,
new Binding { Path = new PropertyPath(nameof(TableViewColumn.Header)) });
}

CalculateHeaderWidths();
Expand Down
Loading
Loading