public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            try
            {
                var source = (IEnumerable)value;
                if (source != null)
                {
                    var tabItems = new List<TabItem>();

                    foreach (object item in source)
                    {
                        var tabItem = new TabItem
                                          {
                                              DataContext = item,
                                              Content = new ContentControl { Template = (ControlTemplate)parameter }
                                          };

                        var binding = new Binding("DisplayName");
                        tabItem.SetBinding(TabItem.HeaderProperty, binding);

                        tabItems.Add(tabItem);
                    }

                    return tabItems;
                }
                return null;
            }
            catch (Exception)
            {
                return null;
            }
        }
Exemplo n.º 2
0
        private TabItem MakeNewTab(FileLoader currentLoader)
        {
            var newTab = new TabItem {DataContext = new FileData(currentLoader)};

            var headerBinding = new Binding("Name");
            headerBinding.Mode = BindingMode.OneTime;
            newTab.SetBinding(HeaderedContentControl.HeaderProperty, headerBinding);

            newTab.Content = new FileView();
            return newTab;
        }
Exemplo n.º 3
0
        private void AddTab(UIElement content, string header)
        {
            var tabItem = new TabItem {
                Content = content,
                Header = header,
            };

            tabItem.SetBinding(VisibilityProperty, new Binding {
                Path = new PropertyPath(VisibilityProperty),
                Source = content
            });

            this.tabControl.Items.Add(tabItem);
        }
Exemplo n.º 4
0
 private static TabItem CreateTabItem()
 {
     var tabItem = new TabItem
     {
         Width = 150,
         Height = 20,
         IsSelected = true,
         Content = CreateNewTab()
     };
     tabItem.SetBinding(HeaderedContentControl.HeaderProperty, new Binding("Content.DataContext.Title")
     {
         RelativeSource = RelativeSource.Self
     });
     return tabItem;
 }
Exemplo n.º 5
0
        private void AddTabItem(object vm)
        {
            var view = new ProviderView();
            var tab = new TabItem
            {
                DataContext = vm,
                Content = new ModernWPF.Controls.ModernContentControl { Content = view }
            };
            tab.SetBinding(TabItem.HeaderProperty, new Binding("Name"));

            theTabs.Items.Add(tab);

            // When there is only 1 Item, the tab can't be rendered without have it selected
            // Don't do Refresh(). This may clear
            // the Selected item, causing issue in the ViewModel
            if (theTabs.SelectedItem == null)
                tab.IsSelected = true;
        }
		private void CreatePages()
		{
			var layers = new TabItem()
				{
					Header = "Слои",
					Content = ElementsViewModel
				};
			Binding visibilityBinding = new Binding("SelectedPlan");
			visibilityBinding.Source = this;
			visibilityBinding.Converter = new NullToVisibilityConverter();
			layers.SetBinding(TabItem.VisibilityProperty, visibilityBinding);

			TabPages = new List<TabItem>()
			{
				layers
			};
			SelectedTabIndex = -1;
		}
Exemplo n.º 7
0
        void AssociationsView_Loaded(object sender, System.Windows.RoutedEventArgs e)
        {
            if (AssociationTabs.Items.Count == 0)
            {
                //Managed Profiles Tab
                TabItem profilesTab = new TabItem();
                profilesTab.Header = "Managed Profiles";
                ProfilesView profilesView = new ProfilesView();
                ProfilesViewModel profilesViewModel = KernelContainer.Kernel.Get<ProfilesViewModel>();
                profilesViewModel.AssociationManagerId = ViewModel.AssociationManagerId;
                profilesViewModel.BookingEnginePanel = BookingEnginePanel;
                profilesView.DataContext = profilesViewModel;
                profilesTab.Content = profilesView;

                //Saved Address Tab
                TabItem savedAddressTab = new TabItem();
                savedAddressTab.Header = "Saved Address";
                SavedAddressListView savedAddressListView = new SavedAddressListView();
                //SavedAddressListViewModel savedAddressListViewModel = KernelContainer.Kernel.Get<SavedAddressListViewModel>();
                //savedAddressListView.DataContext = savedAddressListViewModel;
                savedAddressTab.Content = savedAddressListView;

                TabItem savedBillingTab = new TabItem();
                savedBillingTab.Header = "Saved Billing";
                Segator.Loms.Modules.Associations.Silverlight.SavedBilling.BillingView savedBillingView = new Segator.Loms.Modules.Associations.Silverlight.SavedBilling.BillingView();
                //BillingViewModel savedBillingViewModel = KernelContainer.Kernel.Get<BillingViewModel>();
                //savedBillingView.DataContext = savedBillingViewModel;
                savedBillingTab.Content = savedBillingView;

                TabItem historyTab = new TabItem();
                historyTab.Header = "History";
                HistoryView historyView = new HistoryView();
                HistoryViewModel historyViewModel = KernelContainer.Kernel.Get<HistoryViewModel>();
                historyViewModel.BookingEnginePanel = BookingEnginePanel;
                historyView.DataContext = historyViewModel;

                historyTab.Content = historyView;

                TabItem myAwardsTab = new TabItem();
                myAwardsTab.Header = " Limo Points";
                MyAwardsView myAwardsView = new MyAwardsView();
                myAwardsTab.Content = myAwardsView;

                //My Admin Tab
                TabItem myAdminTab = new TabItem();
                myAdminTab.Header = "My Admin";
                MyAdminView myAdminView = new MyAdminView();
                MyAdminViewModel myAdminViewModel = KernelContainer.Kernel.Get<MyAdminViewModel>();
                myAdminViewModel.AssociationManagerId = ViewModel.AssociationManagerId;
                myAdminView.DataContext = myAdminViewModel;
                myAdminTab.Content = myAdminView;


                AssociationTabs.Items.Add(profilesTab);
                AssociationTabs.Items.Add(savedAddressTab);
                AssociationTabs.Items.Add(savedBillingTab);
                AssociationTabs.Items.Add(historyTab);
                AssociationTabs.Items.Add(myAwardsTab);
                AssociationTabs.Items.Add(myAdminTab);

                Binding b = new Binding("MyAdminTabVisibility");
                b.Source = DataContext;
                myAdminTab.SetBinding(TabItem.VisibilityProperty, b);
            }

        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="seq_"></param>
        public void OpenGraphInNewTab(SequenceBase seq_)
        {
            foreach (TabItem item in tabControl.Items)
            {
                if ((item.DataContext as FlowGraphControlViewModel).ID == seq_.Id)
                {
                    tabControl.SelectedItem = item;
                    return;
                }
            }

            TabItem tab = new TabItem();
            FlowGraphControlViewModel fgvm = FlowGraphManager.Instance.GetViewModelByID(seq_.Id);
            tab.DataContext = fgvm;

            FlowGraphControl fgc = new FlowGraphControl();
            fgc.DataContext = fgvm;
            tab.Content = fgc;

            Binding bind = new Binding("Name");
            bind.Source = fgvm;
            tab.SetBinding(TabItem.HeaderProperty, bind);

            tabControl.SelectedIndex = tabControl.Items.Add(tab);
        }
        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);
        }
Exemplo n.º 10
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);
        }
Exemplo n.º 11
0
		/// <summary>
		/// Creates the user interface elements for a Worker
		/// </summary>
		private void CreateWorkerTabItem( Worker worker )
		{
			// Create UI objects for this worker
			WorkerView view = new WorkerView();
			WorkerViewModel viewModel = new WorkerViewModel();
			TabItem tabItem = new TabItem();

			// Connect events, bindings and UI elements
			viewModel.InitializeBindings( worker ); ;
			view.DataContext = viewModel;
			tabItem.Header = viewModel.WorkerName;
			tabItem.Content = view;
			tabItem.DataContext = viewModel;
			tabItem.SetBinding( TabItem.HeaderProperty, "WorkerName" );

			// Add the Tab to the UI
			m_TabItemsDictionary[ worker ] = tabItem;
			TabItems.Add( tabItem );
		}
Exemplo n.º 12
0
        private void CreatePages()
        {
            var layers = new TabItem()
                {
                    Header = "Слои",
                    Content = ElementsViewModel
                };
            Binding visibilityBinding = new Binding("SelectedPlan");
            visibilityBinding.Source = this;
            visibilityBinding.Converter = (IValueConverter)Application.Current.FindResource("NullToVisibilityConverter");
            layers.SetBinding(TabItem.VisibilityProperty, visibilityBinding);

            TabPages = new List<TabItem>()
            {
                new TabItem()
                {
                    Header = "Планы",
                    Content = PlansTreeViewModel
                },
                layers
            };
        }
        /// <summary>
        /// Adds <see cref="TabItem"/> for the content object
        /// </summary>
        /// <param name="item">Content of the <see cref="TabItems"/></param>
        private void AddTabItem(object item)
        {
            ContentControl contentControl = new ContentControl();
            TabItem tab = new TabItem
            {
                DataContext = item,
                Content = contentControl,
                HeaderTemplate = _tabControl.ItemTemplate
            };

            contentControl.SetBinding(ContentControl.ContentProperty, new Binding());
            tab.SetBinding(TabItem.HeaderProperty, new Binding());

            _tabControl.Items.Add(tab);
        }