none
Menu placement - Menu opening outside of window

    Question

  • I'm trying to add a simple menu in WPF (using C#).  The lack of easy drag-and-drop configuration is a little disappointing but I was able to add the items I wanted:

    (XAML)

    <Window x:Class="TestProgram.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Title="MainWindow" Height="350" Width="525">
        <Grid>
            <DockPanel VerticalAlignment="Top">
                <Menu DockPanel.Dock="Top" >
                    <MenuItem Header="_File">
                        <MenuItem Header="_New" />
                        <Separator />
                        <MenuItem Header="_Open" />
                        <Separator />
                        <MenuItem Header="_Save" />
                        <MenuItem Header="Save As…" />
                        <MenuItem Header="Exit" Click="mnuFileExit_Click" />
                    </MenuItem>
                    <MenuItem Header="_Edit">
                        <MenuItem Header="Cut" />
                        <MenuItem Header="Copy" />
                        <MenuItem Header="Paste" />
                    </MenuItem>
                    <MenuItem Header="_Help">
                        <MenuItem Header="About" />
                    </MenuItem>
                </Menu>
            </DockPanel>
        </Grid>
    </Window>

    However, when I launch the application it opens the menu to the left, going outside the window: 


    1. How can I keep the menu inside?  Why is it doing that? 

    2. I'd also like it to show hot-keys text in the menu, such as "Ctrl-O" next to "Open". know I can manually add them but is there not an automatic way?


    • Edited by DG Osborne Friday, September 12, 2014 3:31 AM
    Friday, September 12, 2014 3:31 AM

Answers

  • Thanks, I am aware it has nothing to do with Visual Studio.  That was my response to unhelpful information that was equally irrelevant.

    Thanks! The problem was solved via that first link:

    • Press Windows Key + R
    • Enter shell:::{80F3F1D5-FECA-45F3-BC32-752C152E456E}
    • Select the "Other" tab
    • In "Handedness", select "Left Handed"

    While I understand the idea behind this, you have to admit it's pretty silly for me to need to choose "Left Handed" from some obscure setting to get the menus to behave normally.  I'm not on a tablet, nor am I using a touch-screen.

    Even if I *were* using a touch-screen, I doubt very much that I would want the so-called "Right Handed" behavior.  I would want the "Left Handed" behavior regardless of which hand I used.




    • Marked as answer by DG Osborne Wednesday, September 24, 2014 12:01 AM
    • Edited by DG Osborne Wednesday, September 24, 2014 12:03 AM
    Tuesday, September 23, 2014 11:58 PM

All replies