private void OpenFile(string filePath) { string fileName = System.IO.Path.GetFileName(filePath); var newTab = new TabItem(); newTab.Header = fileName; int newTabIndex = tabControl.Items.Add(newTab); var logControl = new LogControl2(); newTab.Content = logControl; tabControl.SelectedIndex = newTabIndex; logControl.LoadData(filePath); }