Handle null content when recycling Emulator table rows
This commit is contained in:
1 parent
f32ecf35d5
commit
c2084b6cd1
1 file changed
+7
-2
+7
-2
@@ -185,6 +185,9 @@ internal sealed class MainWindow : Window
|
||||
{
|
||||
try
|
||||
{
|
||||
// Recycling a visible row asks its template to build null content.
|
||||
instances.ItemTemplate?.Build(null);
|
||||
images.ItemTemplate?.Build(null);
|
||||
using var timeout = new CancellationTokenSource(TimeSpan.FromSeconds(20));
|
||||
await RefreshInstances(timeout.Token);
|
||||
await RefreshImages(timeout.Token, true);
|
||||
@@ -194,7 +197,7 @@ internal sealed class MainWindow : Window
|
||||
catch (Exception error)
|
||||
{
|
||||
Console.Error.WriteLine(error);
|
||||
shutdown(1);
|
||||
Dispatcher.UIThread.Post(() => shutdown(1));
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -396,7 +399,9 @@ internal sealed class MainWindow : Window
|
||||
private static Control Table<T>(ListBox list, string columns, string[] headings, Func<T, string[]> cells)
|
||||
where T : class
|
||||
{
|
||||
list.ItemTemplate = new FuncDataTemplate<T>((item, _) => TableRow(columns, cells(item!), false));
|
||||
// Avalonia clears the content to null before reusing a virtualized row.
|
||||
list.ItemTemplate = new FuncDataTemplate<T>((item, _) =>
|
||||
item is null ? null : TableRow(columns, cells(item), false));
|
||||
list.Padding = new Thickness(0);
|
||||
var panel = new DockPanel();
|
||||
var header = new Border
|
||||
|
||||
Reference in new issue
Block a user