public ToolBarButtonProvider RemoveButtonAt(int index) { ToolBarButtonProvider button = null; if (index < toolBar.Buttons.Count) { button = (ToolBarButtonProvider) ProviderFactory.GetProvider(toolBar.Buttons [index]); ProviderFactory.ReleaseProvider(toolBar.Buttons [index]); } return(button); }
public override void FinalizeChildControlStructure() { toolBar.Buttons.UIACollectionChanged -= new CollectionChangeEventHandler(OnCollectionChanged); for (int index = 0; index < toolBar.Buttons.Count; index++) { ToolBarButtonProvider buttonProvider = (ToolBarButtonProvider)ProviderFactory.FindProvider(toolBar.Buttons [index]); RemoveChildProvider(buttonProvider); } OnNavigationChildrenCleared(); base.FinalizeChildControlStructure(); }
#pragma warning disable 169 private void OnCollectionChanged(object sender, CollectionChangeEventArgs e) { if (e.Action == CollectionChangeAction.Add) { ToolBarButtonProvider button = (ToolBarButtonProvider) ProviderFactory.GetProvider(toolBar.Buttons [(int)e.Element]); AddChildProvider(button); } else if (e.Action == CollectionChangeAction.Remove) { ToolBarButtonProvider button = RemoveButtonAt((int)e.Element); RemoveChildProvider(button); } else if (e.Action == CollectionChangeAction.Refresh) { ClearButtonsCollection(); OnNavigationChildrenCleared(); } }