aybe
aybe

Reputation: 16672

Cannot hide WPF Ribbon title bar

I've tried to set a style as explained in this answer but the title bar remains visible.

enter image description here

Any ideas ?

Environment : WPF 4.5 application / Visual Studio 2012 / Windows 8

Upvotes: 1

Views: 1515

Answers (2)

James_UK_DEV
James_UK_DEV

Reputation: 519

You can do it in code behind on the Loaded event. Loaded="Ribbon_OnLoaded"

private void Ribbon_OnLoaded(object sender, RoutedEventArgs e)
    {
        int childControlCount = VisualTreeHelper.GetChildrenCount((System.Windows.Controls.Ribbon.Ribbon)sender);

        if (childControlCount != 0)
        {
            for (int i = 0;
                i < VisualTreeHelper.GetChildrenCount((System.Windows.Controls.Ribbon.Ribbon)sender);
                i++)
            {
                DependencyObject child = VisualTreeHelper.GetChild((System.Windows.Controls.Ribbon.Ribbon)sender, i);

                if (child is Grid)
                {
                    ((Grid)child).RowDefinitions[0].Height = new GridLength(0);
                }
            }
        }
    }

Upvotes: 1

aybe
aybe

Reputation: 16672

The content needs to be hosted inside a RibbonWindow instead.

Upvotes: 0

Related Questions