Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get WPF menus to align like the old win forms menu?

Tags:

wpf

I have a WPF app that I am working on. Everything is very simple at the moment as I've not implemented any of the "meat" yet. One of the things that is bothering some of the users with the prototype is that the menu drops down "backwards" from how it used to in win forms.

enter image description here

What I'm looking to have is the left edge of the menu box line up with the left edge of the word "File" in the parent menu. I've been doing some searching but I don't think I'm hitting the right keywords. I'm not sure if it makes any difference but I'm also using the MVVMLight library by Galasoft.

My question is how do I get the left edge of the menu to line up with the left edge of the "File" text? Thanks ahead of time!

    <Menu Grid.Row="0" Grid.Column="0">
        <MenuItem Header="_File" >
            <MenuItem Header="EnableWatcher" IsCheckable="True" IsChecked="{Binding WatcherEnabled}" />
            <Separator />
            <MenuItem Header="_Exit" />
        </MenuItem>
    </Menu>

EDIT: Here is all of the code in the xaml file.

    <Window x:Class="DonkeySuite.Watcher.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:ViewModel="clr-namespace:DonkeySuite.Watcher.ViewModel"
    Title="MainWindow" Height="350" Width="525" Icon="/DonkeySuite.Watcher;component/BlueFolder.ico">
<Window.DataContext>
    <ViewModel:MainViewModel />
</Window.DataContext>
<!--<i:Interaction.Triggers>
    <i:EventTrigger EventName="Closing">
        <Command:EventToCommand Command="{Binding SaveSettings}"/>
    </i:EventTrigger>
</i:Interaction.Triggers>-->
<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="30" />
        <RowDefinition Height="30" />
        <RowDefinition Height="*" />
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>

    </Grid.ColumnDefinitions>
    <Menu Grid.Row="0" Grid.Column="0">
        <MenuItem Header="_File" >
            <MenuItem Header="EnableWatcher" IsCheckable="True" IsChecked="{Binding WatcherEnabled}" />
            <Separator />
            <MenuItem Header="_Exit" />
        </MenuItem>
    </Menu>

    <Grid Grid.Column="0" Grid.Row="1">
        <Grid.RowDefinitions>

        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="60" />
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="100" />
        </Grid.ColumnDefinitions>
        <TextBlock Grid.Column="0" HorizontalAlignment="Right" VerticalAlignment="Center">Directory:</TextBlock>
        <TextBox Grid.Column="1" Text="{Binding WatchDirectory, Mode=TwoWay}" VerticalAlignment="Center"></TextBox>
        <Button Grid.Column="2" Content="Browse" Command="{Binding BrowseForDirectory}" Height="24" Margin="5, 0, 15, 0">
        </Button>
    </Grid>
</Grid>

like image 573
Frito Avatar asked Jun 28 '12 02:06

Frito


1 Answers

I finally figured it out. I found a link off Microsoft that resolved my issue. Apparently this was happeneing because I have a Wacom tablet on my computer. It has absolutely nothing to do with WPF.

http://answers.microsoft.com/en-us/windows/forum/windows_7-desktop/menus-are-being-right-aligned/cb94ff1e-5c3f-4535-944a-ae5632149a0d

In case the link ends up going away here's the details in a nut-shell.

Press the Windows key + R to bring up the Run dialog box. In the Open line, copy/paste the following line of text.

shell:::{80F3F1D5-FECA-45F3-BC32-752C152E456E}

Press OK.

This will start the Tablet PC Settings configuration dialog (Even if you do not have a Tablet PC).

Select the Other Tab.

In the Handedness section, place a check mark in the Left Handed option.

Click OK.

like image 160
Frito Avatar answered Sep 18 '22 23:09

Frito