我有一个我正在研究的WPF应用程序.目前一切都很简单,因为我还没有实施任何“肉”.使用原型困扰一些用户的事情之一是菜单从赢取表单中的“向后”方向下降.
我期待的是菜单框的左边缘与父菜单中单词“File”的左边缘对齐.我一直在做一些搜索,但我认为我没有找到合适的关键词.我不确定它是否有任何区别,但我也使用Galasoft的MVVMLight库.
我的问题是如何让菜单的左边缘与“文件”文本的左边缘对齐?提前谢谢!
<Menu Grid.Row="0" Grid.Column="0"> <MenuItem Header="_File" > <MenuItem Header="EnableWatcher" IsCheckable="True" IsChecked="{Binding WatcherEnabled}" /> <Separator /> <MenuItem Header="_Exit" /> </MenuItem> </Menu>
<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,15,0"> </Button> </Grid> </Grid>
解决方法
我终于弄明白了.我发现微软的一个链接解决了我的问题.显然这是因为我的计算机上有一台Wacom平板电脑.它与WPF完全无关.
如果链接最终消失,这里是坚果壳中的细节.
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.