/// <summary> /// Adds a PivotItem to the PivotPanel's Children collection /// </summary> /// <param name="item">PivotItem</param> public int AddChild(PivotItem item) { if (_pivotItems == null) { _pivotItems = new List <PivotItem>(); } _pivotItems.Add(item); item.SetParent(this); if (item.PivotHeader != null) { _headerPanel.AddChild(item.PivotHeader); } if (item.PivotContent != null) { Grid.SetRow(item.PivotContent, 1); // Set the item to its initial state item.Initialize(); _rootGrid.Children.Add(item.PivotContent); } return(_pivotItems.Count - 1); }
/// <summary> /// Handles changes to the PivotHeader property. /// </summary> /// <param name="d">PivotItem</param> /// <param name="e">DependencyProperty changed event arguments</param> private static void OnPivotHeaderChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { PivotItem item = (PivotItem)d; FrameworkElement oldPivotHeader = (FrameworkElement)e.OldValue; FrameworkElement newPivotHeader = item.PivotHeader; item.OnPivotHeaderChanged(oldPivotHeader, newPivotHeader); }
/// <summary> /// Adds the newly assigned PivotHeader of the PivotItem to the PivotPanel /// </summary> /// <param name="item">PivotItem</param> internal void UpdatePivotItemHeader(PivotItem item) { if ((_pivotItems.Contains(item)) && (item.PivotHeader != null) && (!_headerPanel.Contains(item.PivotHeader))) { _headerPanel.AddChild(item.PivotHeader); // Activate the First Pivot Item. ActivateFirstPivotItem(); } }
/// <summary> /// Adds the newly assigned PivotHeader of the PivotItem to the PivotPanel /// </summary> /// <param name="item">PivotItem</param> internal void UpdatePivotItemHeader(PivotItem item) { if ((pivotItems.Contains(item)) && (item.PivotHeader != null) && (!headerPanel.Contains((UIElement)item.PivotHeader))) { headerPanel.AddChild(item.PivotHeader as UIElement); // Activate the First Pivot Item. ActivateFirstPivotItem(); } }
/// <summary> /// Sets the First Pivot item as active /// </summary> private void ActivateFirstPivotItem() { // Set the first item as active if ((_pivotItems != null) && (_pivotItems.Count > 0)) { _pivotItems.First().SetActive(true); _currPivotItem = _pivotItems.First(); } }
/// <summary> /// Adds the newly assigned PivotContent of the PivotItem to the PivotPanel /// </summary> /// <param name="item">PivotItem</param> internal void UpdatePivotItemContent(PivotItem item) { if ((_pivotItems.Contains(item)) && (item.PivotContent != null) && (!_rootGrid.Children.Contains(item.PivotContent))) { Grid.SetRow(item.PivotContent, 1); _rootGrid.Children.Add(item.PivotContent); // Activate the First Pivot Item. ActivateFirstPivotItem(); } }
/// <summary> /// Adds the child to the Panel through XAML /// </summary> /// <param name="child">Child to be added</param> /// <returns>Index of the child in the collection</returns> public int AddChild(UIElement child) { PivotItem pItem = child as PivotItem; if (pItem != null) { return(AddChild(pItem)); } return(-1); }
/// <summary> /// Handles the event raised when a header item is selected /// </summary> /// <param name="sender">Header item</param> /// <param name="e">Event Args</param> void OnHeaderSelected(object sender, EventArgs e) { var headerItem = sender as FrameworkElement; if (headerItem == null) { return; } // Find the PivotItem whose header was selected var pItem = _pivotItems.FirstOrDefault(p => p.PivotHeader == headerItem); if ((pItem == null) || (pItem == _currPivotItem)) { return; } _currPivotItem?.SetActive(false); pItem.SetActive(true); _currPivotItem = pItem; }
/// <summary> /// Handles the event raised when a header item is selected /// </summary> /// <param name="sender">Header item</param> /// <param name="e">Event Args</param> void OnHeaderSelected(object sender, EventArgs e) { FrameworkElement headerItem = sender as FrameworkElement; if (headerItem == null) { return; } // Find the PivotItem whose header was selected PivotItem pItem = pivotItems.Where(p => p.PivotHeader == headerItem).FirstOrDefault(); if ((pItem != null) && (pItem != currPivotItem)) { if (currPivotItem != null) { currPivotItem.SetActive(false); } pItem.SetActive(true); currPivotItem = pItem; } }
protected override System.Windows.DependencyObject GetContainerForItemOverride() { PivotItem pi = new PivotItem { PivotHeader = new TextBlock { Text = "header" }, PivotContent = new TextBlock { Text = "content" } }; pi.Content = "yeah"; string[] colors = new string[] { "premier", "second", "third", "fourth" }; PivotHeaderControl tb = new PivotHeaderControl(); tb.FontFamily = new FontFamily("Segoe WP"); tb.FontWeight = FontWeights.Light; tb.ActiveForeground = Brushes.White; tb.InactiveForeground = new SolidColorBrush(Color.FromRgb(48, 48, 48)); tb.FontSize = 64; tb.Content = colors[1]; tb.Margin = new Thickness(20, 0, 0, 0); PivotContentControl pci = new PivotContentControl(); ListBox lb = new ListBox() { FontFamily = new FontFamily("Segoe WP"), FontSize = 32, FontWeight = FontWeights.Light, Foreground = Brushes.Gray, Background = Brushes.Black, BorderThickness = new Thickness(0), }; lb.ItemTemplate = (DataTemplate)this.Resources["ListBoxItemTemplate"]; lb.ItemsSource = "test"; ScrollViewer.SetHorizontalScrollBarVisibility(lb, ScrollBarVisibility.Disabled); lb.HorizontalAlignment = HorizontalAlignment.Stretch; lb.VerticalAlignment = VerticalAlignment.Stretch; lb.Margin = new Thickness(30, 10, 10, 10); pci.Content = lb; pi = new PivotItem { PivotHeader = tb, PivotContent = pci }; return new Button { Content = "oky" }; //return pi; // return base.GetContainerForItemOverride(); }
private void InitializeFluidPivotPanel() { var items = new ObservableCollection<PivotItem>(); var colors = new[] { "first", "second", "disabled", "fourth" }; var brushes = new Brush[] { Brushes.Orange, Brushes.Green, Brushes.Blue, Brushes.Magenta, Brushes.Cyan }; var data = new List<List<TextMessage>> { new List<TextMessage>() { new TextMessage {MainText = "design one", SubText = "Lorem ipsum dolor sit amet"}, new TextMessage {MainText = "design two", SubText = "consectetur adipisicing elit"}, new TextMessage {MainText = "design three", SubText = "sed do eiusmod tempor incididunt"}, new TextMessage {MainText = "design four", SubText = "ut labore et dolore magna aliqua"}, new TextMessage {MainText = "design five", SubText = "Ut enim ad minim veniam"}, new TextMessage {MainText = "design six", SubText = "quis nostrud exercitation ullamco laboris"}, new TextMessage {MainText = "design seven", SubText = "nisi ut aliquip ex ea commodo consequat"} }, new List<TextMessage>() { new TextMessage {MainText = "runtime one", SubText = "Lorem ipsum dolor sit amet"}, new TextMessage {MainText = "runtime two", SubText = "consectetur adipisicing elit"}, new TextMessage {MainText = "runtime three", SubText = "sed do eiusmod tempor incididunt"}, new TextMessage {MainText = "runtime four", SubText = "ut labore et dolore magna aliqua"}, new TextMessage {MainText = "runtime five", SubText = "Ut enim ad minim veniam"}, new TextMessage {MainText = "runtime six", SubText = "quis nostrud exercitation ullamco laboris"}, new TextMessage {MainText = "runtime seven", SubText = "nisi ut aliquip ex ea commodo consequat"} }, new List<TextMessage>() { new TextMessage {MainText = "method one", SubText = "Lorem ipsum dolor sit amet"}, new TextMessage {MainText = "method two", SubText = "consectetur adipisicing elit"}, new TextMessage {MainText = "method three", SubText = "sed do eiusmod tempor incididunt"}, new TextMessage {MainText = "method four", SubText = "ut labore et dolore magna aliqua"}, new TextMessage {MainText = "method five", SubText = "Ut enim ad minim veniam"}, new TextMessage {MainText = "method six", SubText = "quis nostrud exercitation ullamco laboris"}, new TextMessage {MainText = "method seven", SubText = "nisi ut aliquip ex ea commodo consequat"} }, new List<TextMessage>() { new TextMessage {MainText = "solution one", SubText = "Lorem ipsum dolor sit amet"}, new TextMessage {MainText = "solution two", SubText = "consectetur adipisicing elit"}, new TextMessage {MainText = "solution three", SubText = "sed do eiusmod tempor incididunt"}, new TextMessage {MainText = "solution four", SubText = "ut labore et dolore magna aliqua"}, new TextMessage {MainText = "solution five", SubText = "Ut enim ad minim veniam"}, new TextMessage {MainText = "solution six", SubText = "quis nostrud exercitation ullamco laboris"}, new TextMessage {MainText = "solution seven", SubText = "nisi ut aliquip ex ea commodo consequat"} } }; for (var i = 0; i < colors.Count(); i++) { var tb = new PivotHeaderControl { FontFamily = new FontFamily("Segoe UI"), FontWeight = FontWeights.Light, ActiveForeground = Brushes.White, InactiveForeground = new SolidColorBrush(Color.FromRgb(48, 48, 48)), DisabledForeground = Brushes.Red, FontSize = 42, Content = colors[i], Margin = new Thickness(20, 0, 0, 0), IsEnabled = !((i > 0) && ((i % 2) == 0)) }; var pci = new PivotContentControl(); var lb = new ListBox { FontFamily = new FontFamily("Segoe UI"), FontSize = 24, FontWeight = FontWeights.Light, Foreground = brushes[i], Background = new SolidColorBrush(Color.FromRgb(16, 16, 16)), BorderThickness = new Thickness(0), ItemTemplate = (DataTemplate)this.Resources["ListBoxItemTemplate"], ItemsSource = data[i], }; ScrollViewer.SetHorizontalScrollBarVisibility(lb, ScrollBarVisibility.Disabled); lb.HorizontalAlignment = HorizontalAlignment.Stretch; lb.VerticalAlignment = VerticalAlignment.Stretch; lb.Margin = new Thickness(30, 10, 10, 10); pci.Content = lb; var pi = new PivotItem { PivotHeader = tb, PivotContent = pci }; //pi.SetActive(false); items.Add(pi); } RootPivotPanel.ItemsSource = items; RootPivotPanel.Background = new SolidColorBrush(Color.FromRgb(16, 16, 16)); }
/// <summary> /// Handles the event raised when a header item is selected /// </summary> /// <param name="sender">Header item</param> /// <param name="e">Event Args</param> void OnHeaderSelected(object sender, EventArgs e) { var headerItem = sender as FrameworkElement; if (headerItem == null) return; // Find the PivotItem whose header was selected var pItem = _pivotItems.FirstOrDefault(p => p.PivotHeader == headerItem); if ((pItem == null) || (pItem == _currPivotItem)) return; _currPivotItem?.SetActive(false); pItem.SetActive(true); _currPivotItem = pItem; }
/// <summary> /// Handles the event raised when a header item is selected /// </summary> /// <param name="sender">Header item</param> /// <param name="e">Event Args</param> void OnHeaderSelected(object sender, EventArgs e) { FrameworkElement headerItem = sender as FrameworkElement; if (headerItem == null) return; // Find the PivotItem whose header was selected PivotItem pItem = pivotItems.Where(p => p.PivotHeader == headerItem).FirstOrDefault(); if ((pItem != null) && (pItem != currPivotItem)) { if (currPivotItem != null) { currPivotItem.SetActive(false); } pItem.SetActive(true); currPivotItem = pItem; } }
/// <summary> /// Adds the newly assigned PivotContent of the PivotItem to the PivotPanel /// </summary> /// <param name="item">PivotItem</param> internal void UpdatePivotItemContent(PivotItem item) { if ((pivotItems.Contains(item)) && (item.PivotContent != null) && (!rootGrid.Children.Contains((UIElement)item.PivotContent))) { Grid.SetRow(item.PivotContent as UIElement, 1); rootGrid.Children.Add(item.PivotContent as UIElement); // Activate the First Pivot Item. ActivateFirstPivotItem(); } }
/// <summary> /// Adds a PivotItem to the PivotPanel's Children collection /// </summary> /// <param name="item">PivotItem</param> public int AddChild(PivotItem item) { if (pivotItems == null) pivotItems = new List<PivotItem>(); pivotItems.Add(item); item.SetParent(this); if (item.PivotHeader != null) headerPanel.AddChild(item.PivotHeader as UIElement); if (item.PivotContent != null) { Grid.SetRow(item.PivotContent as UIElement, 1); // Set the item to its initial state item.Initialize(); rootGrid.Children.Add(item.PivotContent as UIElement); } return pivotItems.Count - 1; }
/// <summary> /// Sets the First Pivot item as active /// </summary> private void ActivateFirstPivotItem() { // Set the first item as active if ((pivotItems != null) && (pivotItems.Count > 0)) { pivotItems.First().SetActive(true); currPivotItem = pivotItems.First(); } }