Merge pull request #247 from dameng324/taginput-fix-tags-changed

fix TagInput bug when TagsProperty changed.
This commit is contained in:
Dong Bin
2024-05-21 03:07:40 +08:00
committed by GitHub

View File

@@ -165,10 +165,17 @@ public class TagInput : TemplatedControl
{
var newTags = args.GetNewValue<IList<string>>();
var oldTags = args.GetOldValue<IList<string>>();
for (int i = 0; i < Items.Count - 1; i++)
if (Items is AvaloniaList<object> avaloniaList)
{
Items.RemoveAt(Items.Count - 1);
avaloniaList.RemoveRange(0, avaloniaList.Count - 1);
}
else if (Items.Count != 0)
{
Items.Clear();
Items.Add(_textBox);
}
if (newTags != null)
{
for (int i = 0; i < newTags.Count; i++)