Skip to content

Commit

Permalink
added Visibility proeprty for Columns
Browse files Browse the repository at this point in the history
  • Loading branch information
w-ahmad committed Jun 2, 2024
1 parent 730ca9b commit 57588e9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/WinUI.TableView/TableViewColumn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -72,13 +80,12 @@ 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));
public static readonly DependencyProperty MinWidthProperty = DependencyProperty.Register(nameof(MinWidth), typeof(double), typeof(TableViewColumn), new PropertyMetadata(50d));
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));
}
2 changes: 2 additions & 0 deletions src/WinUI.TableView/TableViewHeaderRow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ private void AddHeaders(IEnumerable<TableViewColumn> 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)) });
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/WinUI.TableView/TableViewRow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ private void GenerateCells(IEnumerable<TableViewColumn> 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 }
});
}
}
}
Expand Down

0 comments on commit 57588e9

Please sign in to comment.