private void Button_Click(object sender, RoutedEventArgs e) { SampleView view = new SampleView(); view.LabelText = "A new view #" + (this.tabControl.Items.Count).ToString(); this.tabControl.Items.Add(view); }
private void LoadDummyButtonData() { for (int counter = 0; counter < 2; counter++) { SampleView newView = new SampleView(); newView.LabelText = "View #" + counter.ToString(); this.testViews.Add(newView); } }
private void Button_Click_1(object sender, RoutedEventArgs e) { myTab.ItemsSource = null; SampleView view = new SampleView(); view.LabelText = "Items Collection View"; myTab.Items.Add(view); view = new SampleView(); view.LabelText = "Items Collection View 2"; myTab.Items.Add(view); view = new SampleView(); view.LabelText = "Items Collection View 3"; myTab.Items.Add(view); }
private void Button_Click(object sender, RoutedEventArgs e) { myTab.Items.Clear(); ObservableCollection<UserControl> views = new ObservableCollection<UserControl>(); myTab.ItemsSource = views; for (int counter = 0; counter < 3; counter++) { SampleView newView = new SampleView(); newView.LabelText = "View #" + counter.ToString(); views.Add(newView); } }
private void Button_Click_7(object sender, RoutedEventArgs e) { SampleView view = new SampleView(); view.LabelText = "A new view #" + (this.tabControl.Items.Count).ToString(); FabTabItem item = new FabTabItem(); Uri uri = new Uri("pack://application:,,/SampleProject;component/Graphics/tab_icon.gif", UriKind.RelativeOrAbsolute); BitmapImage bitmap = new BitmapImage(uri); //need to create these element factories to build up the datatemplates completely in code. //This would be much easier to define in XAML, but doing it here for demonstration purposes. //For more info on how this works see: http://stackoverflow.com/questions/248362/how-do-i-build-a-datatemplate-in-c-code FrameworkElementFactory spFactory = new FrameworkElementFactory(typeof(StackPanel)); spFactory.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal); FrameworkElementFactory imgFactory = new FrameworkElementFactory(typeof(Image)); imgFactory.SetValue(Image.SourceProperty, bitmap); FrameworkElementFactory tbFactory = new FrameworkElementFactory(typeof(TextBlock)); //Very important to bind something in our datatemplate to the actual header so that it will show up. tbFactory.SetBinding(TextBlock.TextProperty, new Binding(".")); spFactory.AppendChild(imgFactory); spFactory.AppendChild(tbFactory); DataTemplate headerTemplate = new DataTemplate(); //set the datatemplate's visual tree to the root frameworkelementfactory. headerTemplate.VisualTree = spFactory; //build the visual tree for the HeaderTemplate, but the header itself needs to remain a string //if we want a meaningful string to show up for the screenshot headers on the ContentTabView //and meaningful tab header names to show up in the ContentTab dropdown. item.HeaderTemplate = headerTemplate; item.Header = view.LabelText; item.Content = view; this.tabControl.Items.Add(item); }
private void LoadDummyButtonData() { for (int counter = 0; counter < 2; counter++) { SampleView newView = new SampleView(); newView.LabelText = "View #" + counter.ToString(); this.testViews.Add(newView); } for (int counter = 0; counter < 2; counter++) { ModelObject model = new ModelObject(); model.Name = "Model View #" + counter.ToString(); if (model.Name == "Model View #1") model.AllowClose = true; else model.AllowClose = false; this.testViews.Add(model); } }
private void Button_Click(object sender, RoutedEventArgs e) { SampleView newView = new SampleView(); newView.LabelText = "View #" + testViews.Count.ToString(); testViews.Add(newView); }