From b9966e0a87e00149f6bd58291c83cf6736ac4880 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Pen=CC=83alba?= Date: Tue, 5 Nov 2024 17:15:17 +0100 Subject: [PATCH] Add more data to the completion window to test virtualization --- src/AvaloniaEdit.Demo/MainWindow.xaml.cs | 32 +++++++++++++----------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/AvaloniaEdit.Demo/MainWindow.xaml.cs b/src/AvaloniaEdit.Demo/MainWindow.xaml.cs index 600d6bd..95f42bd 100644 --- a/src/AvaloniaEdit.Demo/MainWindow.xaml.cs +++ b/src/AvaloniaEdit.Demo/MainWindow.xaml.cs @@ -304,20 +304,13 @@ namespace AvaloniaEdit.Demo _completionWindow.Closed += (o, args) => _completionWindow = null; var data = _completionWindow.CompletionList.CompletionData; - data.Add(new MyCompletionData("Item1")); - data.Add(new MyCompletionData("Item2")); - data.Add(new MyCompletionData("Item3")); - data.Add(new MyCompletionData("Item4")); - data.Add(new MyCompletionData("Item5")); - data.Add(new MyCompletionData("Item6")); - data.Add(new MyCompletionData("Item7")); - data.Add(new MyCompletionData("Item8")); - data.Add(new MyCompletionData("Item9")); - data.Add(new MyCompletionData("Item10")); - data.Add(new MyCompletionData("Item11")); - data.Add(new MyCompletionData("Item12")); - data.Add(new MyCompletionData("Item13")); + for (int i = 0; i < 500; i++) + { + data.Add(new MyCompletionData("Item" + i.ToString())); + } + + data.Insert(20, new MyCompletionData("long item to demosntrate dynamic poup resizing")); _completionWindow.Show(); } @@ -443,7 +436,7 @@ namespace AvaloniaEdit.Demo public string Text { get; } // Use this property if you want to show a fancy UIElement in the list. - public object Content => Text; + public object Content => _contentControl ??= BuildContentControl(); public object Description => "Description for " + Text; @@ -454,6 +447,17 @@ namespace AvaloniaEdit.Demo { textArea.Document.Replace(completionSegment, Text); } + + Control BuildContentControl() + { + TextBlock textBlock = new TextBlock(); + textBlock.Text = Text; + textBlock.Margin = new Thickness(5); + + return textBlock; + } + + Control _contentControl; } class ElementGenerator : VisualLineElementGenerator, IComparer