private void AddNewTab() { //create new TabItem & apply style TabItem ti = new TabItem(); ti.Style = (Style)Resources["CloseableTabItem"]; IDirectoryView view = (IDirectoryView)Activator.CreateInstance(ActiveView.GetType()); UserControl viewCtrl = (UserControl)view; viewCtrl.Height = double.NaN;//same as Auto in XAML viewCtrl.VerticalAlignment = VerticalAlignment.Stretch; viewCtrl.Width = double.NaN; viewCtrl.HorizontalAlignment = HorizontalAlignment.Stretch; //events view.ItemExecuted += ActiveView_ItemExecuted; //load last dir to new details view view.LoadDir(DisplayPath, true); //set content listview as content of tabitem ti.Content = view; //add tabitem to tabcontrol tcViews.Items.Insert(tcViews.Items.Count - 1, ti); tcViews.SelectedIndex = tcViews.Items.Count - 2;//QSTN: Why new tab must be selected, to gain header? //bind header Binding bind = new Binding("FileSystem.DirectoryName"); bind.Source = view; ti.SetBinding(TabItem.HeaderProperty, bind); }
public void ApplyLoadedData() { SerializationData data = SerializationHelper.GetData(SerializationKey); Dictionary <string, object> dict = data.Data; int count = (int)dict["Count"]; for (int i = 0; i < count; i++) { Type viewType = (Type)dict[i + "Type"]; IDirectoryView view = (IDirectoryView)Activator.CreateInstance(viewType); FileSystemBase fileSystem = (FileSystemBase)dict[i + "FileSystem"]; //AddNewTab(view, fileSystem); } tcViews.SelectedIndex = (int)dict["ActiveView"]; }
private void AddNewTab(IDirectoryView view, FileSystemBase fileSystem) { //create new TabItem & apply style TabItem ti = new TabItem(); ti.Style = (Style)Resources["CloseableTabItem"]; UserControl viewCtrl = (UserControl)view; viewCtrl.Height = double.NaN;//same as Auto in XAML viewCtrl.VerticalAlignment = VerticalAlignment.Stretch; viewCtrl.Width = double.NaN; viewCtrl.HorizontalAlignment = HorizontalAlignment.Stretch; //events view.ItemExecuted += ActiveView_ItemExecuted; //set file system if (fileSystem != null) { view.ChangeFileSystem(fileSystem); } //set content listview as content of tabitem ti.Content = view; //add tabitem to tabcontrol tcViews.Items.Insert(tcViews.Items.Count - 1, ti); tcViews.SelectedIndex = tcViews.Items.Count - 2;//QSTN: Why new tab must be selected, to gain header? //bind header Binding bind = new Binding("FileSystem.DirectoryName"); bind.Source = view; ti.SetBinding(TabItem.HeaderProperty, bind); }
private void AddNewTab(IDirectoryView view, FileSystemBase fileSystem) { //create new TabItem & apply style TabItem ti = new TabItem(); ti.Style = (Style)Resources["CloseableTabItem"]; UserControl viewCtrl = (UserControl)view; viewCtrl.Height = double.NaN;//same as Auto in XAML viewCtrl.VerticalAlignment = VerticalAlignment.Stretch; viewCtrl.Width = double.NaN; viewCtrl.HorizontalAlignment = HorizontalAlignment.Stretch; //events view.ItemExecuted += ActiveView_ItemExecuted; //set file system if (fileSystem != null) view.ChangeFileSystem(fileSystem); //set content listview as content of tabitem ti.Content = view; //add tabitem to tabcontrol tcViews.Items.Insert(tcViews.Items.Count - 1, ti); tcViews.SelectedIndex = tcViews.Items.Count - 2;//QSTN: Why new tab must be selected, to gain header? //bind header Binding bind = new Binding("FileSystem.DirectoryName"); bind.Source = view; ti.SetBinding(TabItem.HeaderProperty, bind); }