示例#1
0
        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);
        }
示例#2
0
 /// <summary>
 /// Loads directory content into control
 /// </summary>
 /// <param name="dir">Path to directory to show</param>
 public void LoadDir(string dir, bool saveInHistory)
 {
     DisableSimpleSearch();
     ActiveView.LoadDir(dir, saveInHistory);
 }