From 11ec9e3ede06b74d16ed47377765ce2f9cd0c186 Mon Sep 17 00:00:00 2001 From: Coolkeke <37786276+Coolkeke@users.noreply.github.com> Date: Sat, 16 Dec 2023 04:52:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=A0=87=E7=AD=BE=E8=BE=93?= =?UTF-8?q?=E5=85=A5=E6=A1=86BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 解决控件在VM绑定是照成的newTags和oldTags空值以及下标越界问题 --- src/Ursa/Controls/TagInput/TagInput.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Ursa/Controls/TagInput/TagInput.cs b/src/Ursa/Controls/TagInput/TagInput.cs index f0f0c69..c888fb5 100644 --- a/src/Ursa/Controls/TagInput/TagInput.cs +++ b/src/Ursa/Controls/TagInput/TagInput.cs @@ -143,10 +143,12 @@ public class TagInput : TemplatedControl { Items.RemoveAt(Items.Count - 1); } - - for (int i = 0; i < newTags.Count; i++) + if (newTags != null) { - Items.Insert(Items.Count - 1, newTags[i]); + for (int i = 0; i < newTags.Count; i++) + { + Items.Add(newTags[i]); + } } if (oldTags is INotifyCollectionChanged inccold)