Skip to content

Commit 0994bc2

Browse files
committed
fixed selected cells content gethering issue
1 parent 6a077b9 commit 0994bc2

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

src/SampleApp/MainWindow.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<table:TableView x:Name="tableView"
3131
Grid.Row="1"
3232
Margin="16"
33-
SelectionMode="Extended">
33+
ShowExportOptions="True">
3434
<table:TableView.Columns>
3535
<table:TableViewTextColumn Header="Rank"
3636
Binding="{Binding Rank}" />

src/WinUI.TableView/TableView.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,6 @@ private string GetCellsContent(IEnumerable<TableViewCellSlot> slots, bool includ
315315
return string.Empty;
316316
}
317317

318-
var minRow = slots.Select(x => x.Row).Min();
319-
var maxRow = slots.Select(x => x.Row).Max();
320318
var minColumn = slots.Select(x => x.Column).Min();
321319
var maxColumn = slots.Select(x => x.Column).Max();
322320

@@ -328,7 +326,7 @@ private string GetCellsContent(IEnumerable<TableViewCellSlot> slots, bool includ
328326
stringBuilder.AppendLine(GetHeadersContent(separator, minColumn, maxColumn));
329327
}
330328

331-
for (var row = minRow; row <= maxRow; row++)
329+
foreach(var row in slots.Select(x => x.Row).Distinct())
332330
{
333331
var item = Items[row];
334332
var type = ItemsSource?.GetType() is { } listType && listType.IsGenericType ? listType.GetGenericArguments()[0] : item?.GetType();
@@ -338,7 +336,7 @@ private string GetCellsContent(IEnumerable<TableViewCellSlot> slots, bool includ
338336
if (Columns.VisibleColumns[col] is not TableViewBoundColumn column ||
339337
!slots.Contains(new TableViewCellSlot(row, col)))
340338
{
341-
stringBuilder.Append('\t');
339+
stringBuilder.Append(separator);
342340
continue;
343341
}
344342

0 commit comments

Comments
 (0)