MetroWhite WindowChrome File menu to left of title?

WPF Studio, Themes, and Shared Library for WPF Forum

Posted 6 years ago by Chris Ray
Version: 12.2.0573
Avatar

Hey guys. I was wondering if it's possible using the WindowChrome/Metro-White theme, TitleBarContentTemplate strategy to get a Menu to appear to the LEFT of the title text, instead of the right.

Using the below code, I was able to get a Menu to appear at the far right (left of the close/minimize buttons)

 

<Window x:Class="testtest.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:shared="http://schemas.actiprosoftware.com/winfx/xaml/shared"
xmlns:themes="http://schemas.actiprosoftware.com/winfx/xaml/themes"
xmlns:this="clr-namespace:testtest"
Title="Metro-Style Window"
Width="1050" Height="750" ResizeMode="CanResizeWithGrip"
TextOptions.TextFormattingMode="Display"
themes:ThemeManager.Theme="MetroWhite"
>
    <themes:WindowChrome.Chrome>
        <themes:WindowChrome IconMargin="10,4,10,4" >

            <themes:WindowChrome.TitleBarContentTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">
                        <Menu>
                            <MenuItem Header="FILE">
                                <MenuItem Command="ApplicationCommands.New" />
                                <MenuItem Command="ApplicationCommands.Open" />
                                <MenuItem Command="ApplicationCommands.Save" />
                                <Separator />
                                <MenuItem Command="ApplicationCommands.Close" />
                                <Separator />
                                <MenuItem Header="Exit" Click="OnFileExitMenuItemClick" />
                            </MenuItem>
                        </Menu>
                    </StackPanel>
                </DataTemplate>
            </themes:WindowChrome.TitleBarContentTemplate>
        </themes:WindowChrome>
    </themes:WindowChrome.Chrome>
    <this:MainControl x:Name="mainControl" />
</Window>

 

But I would prefer it to appear to the left of the Title (perhaps have the title centered), and to the right of the Icon. This "feels" more natural to users in my humble opinion.

Comments (3)

Answer - Posted 6 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Chris,

I'm sorry but the title bar content is fixed to be next to the window system buttons.  In order to change that, you'd need to completely clone our default templates used by WindowChrome and tweak them for your needs.  That may be more work than you'd want to get into though since there are three templates (glass, non-glass, and classic) and you'd have to update all of them.


Actipro Software Support

Posted 6 years ago by Chris Ray
Avatar

Ok. Might be a feature to consider for next release, options to center the title (like office) as well as place content to the right of the icon, left of the title.

Thanks.

Posted 3 years ago by Chien A.
Avatar

This is something we'd be interested in as well, but in the meantime, just sharing that it is possible to achieve more or less the same thing by simply adding a label or panel after the menu, and dynamically resizing it as appropriate on SizeChanged event of the Window.

For size calculations, references to other non-DataTemplate controls in titlebar can be obtained via live visual tree and VisualTreeHelper.

Also should handle the label/panel Click and DoubleClick events and call Window.DragMove or change Window.WindowState repectively.

[Modified 3 years ago]

The latest build of this product (v2019.1 build 0681) was released 9 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.