diff --git a/src/WinUI.TableView/TableViewColumn.cs b/src/WinUI.TableView/TableViewColumn.cs index 2c4e6e4..726ddce 100644 --- a/src/WinUI.TableView/TableViewColumn.cs +++ b/src/WinUI.TableView/TableViewColumn.cs @@ -62,6 +62,14 @@ internal set } } + public Visibility Visibility + { + get => (Visibility)GetValue(VisibilityProperty); + set => SetValue(VisibilityProperty, value); + } + + internal double DesiredWidth { get; set; } + public bool IsAutoGenerated { get; internal set; } private void EnsureHeaderStyle() @@ -72,8 +80,6 @@ private void EnsureHeaderStyle() } } - internal double DesiredWidth { get; set; } - public static readonly DependencyProperty HeaderStyleProperty = DependencyProperty.Register(nameof(HeaderStyle), typeof(Style), typeof(TableViewColumn), new PropertyMetadata(null, (d, _) => ((TableViewColumn)d).EnsureHeaderStyle())); public static readonly DependencyProperty HeaderProperty = DependencyProperty.Register(nameof(Header), typeof(object), typeof(TableViewColumn), new PropertyMetadata(null)); public static readonly DependencyProperty WidthProperty = DependencyProperty.Register(nameof(Width), typeof(double), typeof(TableViewColumn), new PropertyMetadata(200d)); @@ -81,4 +87,5 @@ private void EnsureHeaderStyle() public static readonly DependencyProperty MaxWidthProperty = DependencyProperty.Register(nameof(MaxWidth), typeof(double), typeof(TableViewColumn), new PropertyMetadata(double.PositiveInfinity)); public static readonly DependencyProperty CanResizeProperty = DependencyProperty.Register(nameof(CanResize), typeof(bool), typeof(TableViewColumn), new PropertyMetadata(true)); public static readonly DependencyProperty IsReadOnlyProperty = DependencyProperty.Register(nameof(IsReadOnly), typeof(bool), typeof(TableViewColumn), new PropertyMetadata(false)); -} + public static readonly DependencyProperty VisibilityProperty = DependencyProperty.Register(nameof(Visibility), typeof(Visibility), typeof(TableViewColumn), new PropertyMetadata(Visibility.Visible)); +} \ No newline at end of file diff --git a/src/WinUI.TableView/TableViewHeaderRow.cs b/src/WinUI.TableView/TableViewHeaderRow.cs index 23ce2e9..fe4ecfb 100644 --- a/src/WinUI.TableView/TableViewHeaderRow.cs +++ b/src/WinUI.TableView/TableViewHeaderRow.cs @@ -141,6 +141,8 @@ private void AddHeaders(IEnumerable columns, int index = -1) new Binding { Path = new PropertyPath(nameof(TableViewColumn.MinWidth)) }); header.SetBinding(MaxWidthProperty, new Binding { Path = new PropertyPath(nameof(TableViewColumn.MaxWidth)) }); + header.SetBinding(VisibilityProperty, + new Binding { Path = new PropertyPath(nameof(TableViewColumn.Visibility)) }); } } } diff --git a/src/WinUI.TableView/TableViewRow.cs b/src/WinUI.TableView/TableViewRow.cs index cd8287e..5d36a21 100644 --- a/src/WinUI.TableView/TableViewRow.cs +++ b/src/WinUI.TableView/TableViewRow.cs @@ -97,6 +97,11 @@ private void GenerateCells(IEnumerable columns, int index = -1) Path = new PropertyPath($"{nameof(TableViewCell.Column)}.{nameof(TableViewColumn.MaxWidth)}"), RelativeSource = new RelativeSource { Mode = RelativeSourceMode.Self } }); + cell.SetBinding(VisibilityProperty, new Binding + { + Path = new PropertyPath($"{nameof(TableViewCell.Column)}.{nameof(TableViewColumn.Visibility)}"), + RelativeSource = new RelativeSource { Mode = RelativeSourceMode.Self } + }); } } }