From 01fabde430375504353815dea6f1cb6a74463443 Mon Sep 17 00:00:00 2001 From: Dameng <313880747@qq.com> Date: Mon, 20 May 2024 14:36:45 +0800 Subject: [PATCH] fix TagInput bug when TagsProperty changed. --- src/Ursa/Controls/TagInput/TagInput.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Ursa/Controls/TagInput/TagInput.cs b/src/Ursa/Controls/TagInput/TagInput.cs index 920f01c..7b93b26 100644 --- a/src/Ursa/Controls/TagInput/TagInput.cs +++ b/src/Ursa/Controls/TagInput/TagInput.cs @@ -165,10 +165,14 @@ public class TagInput : TemplatedControl { var newTags = args.GetNewValue>(); var oldTags = args.GetOldValue>(); - for (int i = 0; i < Items.Count - 1; i++) + + // remove all tags except the textbox + int count = Items.Count; + for (int i = 0; i < count - 1; i++) { - Items.RemoveAt(Items.Count - 1); + Items.RemoveAt(0); } + if (newTags != null) { for (int i = 0; i < newTags.Count; i++)