private void _buttonCloseTab_Click(object sender, RoutedEventArgs e) { Button button = sender as Button; if ((button == null) || (button.Parent == null)) { return; } Grid grid = button.Parent as Grid; if (grid == null) { return; } foreach (var item in grid.Children) { if (item is Label) { ContentPresenter contentPresenter = (item as Label).Content as ContentPresenter; if (contentPresenter != null) { CloseTabRequest?.Invoke(contentPresenter.Content, null); } } } }
public void OnBeforeClose(IWebBrowser browserControl, IBrowser browser) { Thread thread = new Thread(() => { CloseTabRequest?.Invoke(browser, EventArgs.Empty); }); thread.Start(); }