Beispiel #1
0
        /// <summary>
        /// 选中数据移动方法
        /// </summary>
        private async Task TransferItems(List <SelectedItem> source, List <SelectedItem> target)
        {
            if (!IsDisabled && Items != null)
            {
                var items = source.Where(i => i.Active).ToList();
                source.RemoveAll(i => items.Contains(i));
                target.AddRange(items);

                LeftItems.ForEach(i =>
                {
                    var item = Items.FirstOrDefault(item => item.Value == i.Value && item.Text == i.Text && item.GroupName == i.GroupName);
                    if (item != null)
                    {
                        item.Active = false;
                    }
                });
                RightItems.ForEach(i =>
                {
                    var item = Items.FirstOrDefault(item => item.Value == i.Value && item.Text == i.Text && item.GroupName == i.GroupName);
                    if (item != null)
                    {
                        item.Active = true;
                    }
                });

                Value = default;
                CurrentValueAsString = string.Join(",", RightItems.Select(i => i.Value));

                if (OnSelectedItemsChanged != null)
                {
                    await OnSelectedItemsChanged.Invoke(RightItems);
                }
            }
        }
Beispiel #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="value"></param>
 /// <param name="result"></param>
 /// <param name="validationErrorMessage"></param>
 /// <returns></returns>
 protected override bool TryParseValueFromString(string value, out TValue result, out string?validationErrorMessage)
 {
     validationErrorMessage = null;
     if (typeof(TValue) == typeof(string))
     {
         result = (TValue)(object)value;
     }
     else if (typeof(IEnumerable <string>).IsAssignableFrom(typeof(TValue)))
     {
         var v = value.Split(",", StringSplitOptions.RemoveEmptyEntries);
         result = (TValue)(object)new List <string>(v);
     }
     else if (typeof(IEnumerable <SelectedItem>).IsAssignableFrom(typeof(TValue)))
     {
         result = (TValue)(object)RightItems.Select(i => new SelectedItem(i.Value, i.Text)).ToList();
     }
     else
     {
         result = default !;