/// <summary> /// Provides derived classes an opportunity to handle changes to the PivotHeader property. /// </summary> /// <param name="oldPivotHeader">Old Value</param> /// <param name="newPivotHeader">New Value</param> protected void OnPivotHeaderChanged(FrameworkElement oldPivotHeader, FrameworkElement newPivotHeader) { if (parent != null) { parent.UpdatePivotItemHeader(this); } IPivotHeader header = newPivotHeader as IPivotHeader; if (header != null) { header.SetActive(false); } }
/// <summary> /// Adds a child to the HeaderPanel /// </summary> /// <param name="child">Child to be added</param> public void AddChild(UIElement child) { if (child == null) { return; } lock (syncObject) { Dispatcher.BeginInvoke(new Action(() => { child.Opacity = 0; // Get the Desired size of the child child.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity)); // Check if the child needs to be added at the end or inserted in between if ((Children.Count == 0) || (Children[Children.Count - 1] == headerCollection.Last())) { child.RenderTransform = CreateTransform(child); Children.Add(child); headerCollection.Add(child); addFadeInSB.Begin((FrameworkElement)child); } else { var lastChild = Children[Children.Count - 1]; Children.Add(child); int index = headerCollection.IndexOf(lastChild) + 1; // Insert the new child after the last child in the header collection if (index >= 1) { double newLocationX = ((TranslateTransform)(((TransformGroup)headerCollection[index].RenderTransform).Children[0])).X; headerCollection.Insert(index, child); child.RenderTransform = CreateTransform(new Point(newLocationX, 0.0)); InsertChild(child, index + 1); } } // Subscribe to the HeaderSelected event and set Active property to false IPivotHeader headerItem = child as IPivotHeader; if (headerItem != null) { headerItem.HeaderSelected += new EventHandler(OnHeaderSelected); } })); } }
/// <summary> /// Removes all the children from the header /// </summary> public void ClearHeader() { foreach (UIElement item in headerCollection) { IPivotHeader headerItem = item as IPivotHeader; if (headerItem != null) { // Unsubscribe headerItem.HeaderSelected -= OnHeaderSelected; } } headerCollection.Clear(); Children.Clear(); }
/// <summary> /// Initializes the PivotItem /// </summary> public void Initialize() { // Set the header as inactive if (PivotHeader != null) { IPivotHeader header = PivotHeader as IPivotHeader; if (header != null) { header.SetActive(false); } } // Make the PivotContent invisible if (PivotContent != null) { ((FrameworkElement)PivotContent).Visibility = Visibility.Collapsed; } }
/// <summary> /// Activates/Deactivates the Pivot Header and Pivot Content /// based on the 'isActive' flag. /// </summary> /// <param name="isActive">Flag to indicate whether the Pivot Header and Pivot Content should be Activated or Decativated</param> public void SetActive(bool isActive) { if (PivotHeader != null) { IPivotHeader header = PivotHeader as IPivotHeader; if (header != null) { header.SetActive(isActive); } } if (PivotContent != null) { IPivotContent content = PivotContent as IPivotContent; if (content != null) { content.SetActive(isActive); } else { PivotContent.Visibility = isActive ? Visibility.Visible : Visibility.Collapsed; } } }