/// <summary> /// OnParametersSet 方法 /// </summary> protected override void OnParametersSet() { base.OnParametersSet(); LeftPanelText ??= Localizer[nameof(LeftPanelText)]; RightPanelText ??= Localizer[nameof(RightPanelText)]; var list = CurrentValueAsString.Split(',', StringSplitOptions.RemoveEmptyEntries); LeftItems.Clear(); RightItems.Clear(); Items ??= Enumerable.Empty <SelectedItem>(); // 左侧移除 LeftItems.AddRange(Items); LeftItems.RemoveAll(i => list.Any(l => l == i.Value)); // 右侧插入 foreach (var t in list) { var item = Items.FirstOrDefault(i => i.Value == t); if (item != null) { RightItems.Add(item); } } }
/// <summary> /// OnInitialized 方法 /// </summary> protected override void OnInitialized() { base.OnInitialized(); if (Items != null) { LeftItems.AddRange(Items.Where(i => !i.Active)); RightItems.AddRange(Items.Where(i => i.Active)); } }
private void ResetItems() { LeftItems.Clear(); RightItems.Clear(); if (Items != null) { LeftItems.AddRange(Items.Where(i => !i.Active)); } if (Items != null) { RightItems.AddRange(Items.Where(i => i.Active)); } }