/// <summary> /// Populate the Tab with samples name for a given control. /// </summary> /// <param name="sampleAssembly">Name of the sample assembly.</param> /// <param name="controlName">Name of the control.</param> private void PopulateSamplesTab(Assembly sampleAssembly, string controlName) { if (SamplesTab == null) { return; } // Unhook this event when dynamically before adding new tabs. SamplesTab.SelectionChanged -= OnSamplesTabSelectionChanged; if (SamplesTab.Items.Count > 0) { SamplesTab.Items.Clear(); } // Construct a sorted list of samples IList <SampleBrowserItem> samples = new List <SampleBrowserItem>(); foreach (Type type in sampleAssembly.GetTypes()) { SampleAttribute attribute = type.GetCustomAttributes(typeof(SampleAttribute), false).OfType <SampleAttribute>().FirstOrDefault(); CategoryAttribute categoryAttribute = type.GetCustomAttributes(typeof(CategoryAttribute), false).OfType <CategoryAttribute>().FirstOrDefault(); if (attribute != null && categoryAttribute != null) { if (categoryAttribute.Category.Equals(controlName)) { SampleBrowserItem.AddSample(samples, type, attribute); } } } // Populate the Tab Control with the samples. foreach (SampleBrowserItem item in samples) { TabItem tabItem = new TabItem(); if (SampleTabItemStyle != null) { tabItem.Style = SampleTabItemStyle; } tabItem.Header = item; SamplesTab.Items.Add(tabItem); } // Hook up this event when done creating the Sample tabs. SamplesTab.SelectionChanged += OnSamplesTabSelectionChanged; // Select first tab if (SamplesTab.Items.Count > 0) { (SamplesTab.Items[0] as TabItem).IsSelected = true; LoadSample(); } }
/// <summary> /// Populate the Tab with samples name for a given control. /// </summary> /// <param name="controlName">Name of the control.</param> private void PopulateSamplesTab(string controlName) { if (SamplesTab == null) { return; } // Unhook this event when dynamically before adding new tabs. SamplesTab.SelectionChanged -= OnSamplesTabSelectionChanged; if (SamplesTab.Items.Count > 0) { SamplesTab.Items.Clear(); } // Construct a sorted list of samples IList <SampleBrowserItem> samples = new List <SampleBrowserItem>(); foreach (var sample in Samples) { if (controlName.Equals(sample.Metadata.Category)) { SampleBrowserItem.AddSample(samples, sample); } } // Populate the Tab Control with the samples. foreach (SampleBrowserItem item in samples) { TabItem tabItem = new TabItem(); if (SampleTabItemStyle != null) { tabItem.Style = SampleTabItemStyle; } tabItem.Header = item; SamplesTab.Items.Add(tabItem); } // Hook up this event when done creating the Sample tabs. SamplesTab.SelectionChanged += OnSamplesTabSelectionChanged; // Select first tab if (SamplesTab.Items.Count > 0) { (SamplesTab.Items[0] as TabItem).IsSelected = true; LoadSample(); } }