Sangadji Sangadji - 3 months ago 84
C# Question

How to increase pivot header height in UWP?

I currently creating apps in UWP (Universal Windows Platform). I was using pivot control and it seems I couldn't change the pivot item header height! It stays at 68 pixels. I have no idea which element should I modify to change it.

See this image for better explanation (click for full image):
unchanged pivot height

Answer

I think i use same template than you.

So, to modify height i set Height on HeaderClipper (see screenshot below) on pivot style :

enter image description here

Hope this will help you.


UPDATE: Because pivot header height is static and can not be more than a small size, we have to set height manually after page is loaded

private void Page_Loaded(object sender, RoutedEventArgs e)
{
    foreach (PivotHeaderItem phItem in FindVisualChildren<PivotHeaderItem(mainPivot))
     {
         phItem.Height = 110;
    }
}

//Find all children
public static IEnumerable<T> FindVisualChildren<T>(DependencyObject depObj) where T : DependencyObject
{
    if (depObj != null)
    {
        for (int i = 0; i < VisualTreeHelper.GetChildrenCount(depObj); i++)
        {
            DependencyObject child = VisualTreeHelper.GetChild(depObj, i);
            if (child != null && child is T)
            {
                yield return (T)child;
            }

            foreach (T childOfChild in FindVisualChildren<T>(child))
            {
                yield return childOfChild;
            }
        }
    }
}

ref: https://social.msdn.microsoft.com/Forums/sqlserver/en-US/8c123ae3-2884-4d40-a5d1-0a22355fcd5f/uwpxamlhow-to-increase-pivot-header-height-in-uwp?forum=wpdevelop