Skip to content

Sorting with Row Details template open get's mismatched to wrong parent #328

@jpageacsys

Description

@jpageacsys

Description:

If rows have a detail template and you open one then sort by a column, sometimes the detail template will be re-assigned to the wrong header.

Steps to Reproduce:

Create a table with a RowDetailsTemplate and another column header. Then expand one and sort. Here's some code that I used to reproduce this behavior:

<Window
    x:Class="TestTable.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:TestTable"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:tv="using:WinUI.TableView"
    mc:Ignorable="d"
    Title="TestTable">

    <Window.SystemBackdrop>
        <MicaBackdrop />
    </Window.SystemBackdrop>

    <Grid>
        <Grid.DataContext>
            <local:MainViewModel/>
        </Grid.DataContext>
        <tv:TableView ItemsSource="{Binding TestItems}">
            <tv:TableView.RowDetailsTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding CompletedDate}"/>
                </DataTemplate>
            </tv:TableView.RowDetailsTemplate>
        </tv:TableView>
    </Grid>
</Window>
public partial class TestModel : ObservableRecipient
{
    [ObservableProperty]
    public partial string Title { get; set; } = "Test Title";
    [ObservableProperty]
    public partial DateTimeOffset? CompletedDate { get; set; } = DateTimeOffset.Now;
    [ObservableProperty]
    public partial User? User { get; set; } = new User();
}

public partial class User :ObservableRecipient
{
    [ObservableProperty]
    public partial string Name { get; set; } = "Test User";
}
public sealed partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
    }
}

public partial class MainViewModel : ObservableRecipient
{
    public MainViewModel()
    {
        TestItems =
        [
            new TestModel { Title = "Task 1", CompletedDate = DateTimeOffset.Now.AddDays(-1), User = new User { Name = "User 1" } },
            new TestModel { Title = "Task 2", CompletedDate = DateTimeOffset.Now.AddDays(-2), User = new User { Name = "User 2" } },
            new TestModel { Title = "Task 3", CompletedDate = null, User = new User { Name = "User 3" } },
        ];
    }
    [ObservableProperty]
    public partial List<TestModel> TestItems { get; set; }
}

Expected behavior:

The row details should follow the matching parent.

Screenshots:

Here's a video of it happening. The row details template includes the completed date and Task 3 doesn't have a completed date but if you re-sort, it get's one of the other tasks' completed date:

20260317-1342-06.5841508.mp4

Environment:

  • Package Version: 1.4.0
  • WinAppSDK Version: 1.8.260209005

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions