修复TagIpoutBUG
修复TextBox值为Null无法删除问题以及AllowDuplicates为false状态 VM中的Tags为null时的异常状态问题
This commit is contained in:
@@ -210,24 +210,22 @@ public class TagInput : TemplatedControl
|
||||
values = new[] { _textBox.Text };
|
||||
}
|
||||
|
||||
if (!AllowDuplicates)
|
||||
{
|
||||
if (!AllowDuplicates && Tags != null)
|
||||
values = values.Distinct().Except(Tags).ToArray();
|
||||
}
|
||||
|
||||
for (int i = 0; i < values.Length; i++)
|
||||
{
|
||||
int index = Items.Count - 1;
|
||||
// Items.Insert(index, values[i]);
|
||||
Tags.Insert(index, values[i]);
|
||||
Tags?.Insert(index, values[i]);
|
||||
}
|
||||
|
||||
_textBox.Text = "";
|
||||
}
|
||||
}
|
||||
else if (args.Key == Key.Delete || args.Key == Key.Back)
|
||||
{
|
||||
if (_textBox.Text?.Length == 0)
|
||||
{
|
||||
if (string.IsNullOrEmpty(_textBox.Text)||_textBox.Text?.Length == 0)
|
||||
{
|
||||
if (Tags.Count == 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user