private void OnItemStateChanged(Object sender, ItemChangedEventArgs e) { if (!_allowToSave) { return; } var itemInfo = e.ItemInfo; if (e.Checked) { var itemControl = new ItemControl(itemInfo, this); xtraTabControl.TabPages.Add(itemControl); itemControl.LoadData(); } else { var itemControl = xtraTabControl.TabPages .OfType <ItemControl>() .FirstOrDefault(control => String.Equals(control.ItemInfo.Id, itemInfo.Id, StringComparison.OrdinalIgnoreCase)); if (itemControl != null) { SlideContainer.EditedContent.ApproachState.TabA.Items.RemoveAll(item => String.Equals(item.Id, itemControl.ItemInfo.Id, StringComparison.OrdinalIgnoreCase)); xtraTabControl.TabPages.Remove(itemControl); } } SlideContainer.RaiseSlideTypeChanged(); RaiseEditValueChanged(); }
public override void LoadData() { _allowToSave = false; Contents.LoadData(); foreach (var itemControl in xtraTabControl.TabPages.OfType <ItemControl>().ToList()) { xtraTabControl.TabPages.Remove(itemControl); } foreach (var itemState in SlideContainer.EditedContent.ApproachState.TabA.Items.OrderBy(item => item.Index)) { var itemInfo = CustomTabInfo.ApproachItems.FirstOrDefault(item => String.Equals(item.Id, itemState.Id, StringComparison.OrdinalIgnoreCase)); if (itemInfo != null) { var itemControl = new ItemControl(itemInfo, this); xtraTabControl.TabPages.Add(itemControl); itemControl.LoadData(); } } _allowToSave = true; }