Skip to content

Commit

Permalink
moved TableViewCellsPresenter class to own file
Browse files Browse the repository at this point in the history
  • Loading branch information
w-ahmad committed Jul 6, 2024
1 parent c27f5e3 commit edd7db5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
15 changes: 15 additions & 0 deletions src/WinUI.TableView/TableViewCellsPresenter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Microsoft.UI.Xaml.Controls;
using System.Collections.Generic;
using System.Linq;

namespace WinUI.TableView;

public class TableViewCellsPresenter : StackPanel
{
public TableViewCellsPresenter()
{
Orientation = Orientation.Horizontal;
}

public IList<TableViewCell> Cells => Children.OfType<TableViewCell>().ToList().AsReadOnly();
}
14 changes: 2 additions & 12 deletions src/WinUI.TableView/TableViewRow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace WinUI.TableView;

public class TableViewRow : ListViewItem
{
private TableViewCellPresenter? _cellPresenter;
private TableViewCellsPresenter? _cellPresenter;

public TableViewRow()
{
Expand All @@ -27,7 +27,7 @@ protected override void OnContentChanged(object oldContent, object newContent)

if (_cellPresenter is null)
{
_cellPresenter = ContentTemplateRoot as TableViewCellPresenter;
_cellPresenter = ContentTemplateRoot as TableViewCellsPresenter;
if (_cellPresenter is not null)
{
_cellPresenter.Children.Clear();
Expand Down Expand Up @@ -200,13 +200,3 @@ public TableView TableView

public static readonly DependencyProperty TableViewProperty = DependencyProperty.Register(nameof(TableView), typeof(TableView), typeof(TableViewRow), new PropertyMetadata(default, OnTableViewChanged));
}

public class TableViewCellPresenter : StackPanel
{
public TableViewCellPresenter()
{
Orientation = Orientation.Horizontal;
}

public IList<TableViewCell> Cells => Children.OfType<TableViewCell>().ToList().AsReadOnly();
}
2 changes: 1 addition & 1 deletion src/WinUI.TableView/Themes/TableView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<Setter Property="ItemTemplate">
<Setter.Value>
<DataTemplate>
<local:TableViewCellPresenter IsTabStop="False"/>
<local:TableViewCellsPresenter IsTabStop="False"/>
</DataTemplate>
</Setter.Value>
</Setter>
Expand Down

0 comments on commit edd7db5

Please sign in to comment.