简体   繁体   English

C#:调试时未显示菜单项

[英]C#: menu item not showing when debugging

So I have added a "Menu" item to my program and though properties: 因此,我在程序中通过属性添加了“菜单”项:

IsEnabled: (is checked)
visibility: Visible

And my .xaml shows: 我的.xaml显示:

 <Grid>
    <Menu Height="26" HorizontalAlignment="Left" Margin="-1,0,0,0" Name="menu1" VerticalAlignment="Top" Width="504" Opacity="88">
    <MenuItem Header="_Menu"/>
    <MenuItem Header="_View"/>
    <MenuItem Header="_Edit"/>
    </Menu>
</Grid>

When I debug the program the "Menu" or any of the MenuItems does not show up on the Active Windows Form. 当我调试程序时,“菜单”或任何MenuItems都不会显示在Active Windows窗体上。

Any thoughts? 有什么想法吗?

Add right after your window element <DockPanel Width="Auto" Height="Auto" LastChildFill="True"> 在窗口元素之后添加<DockPanel Width="Auto" Height="Auto" LastChildFill="True">

And then add this attribute into your menu element: DockPanel.Dock="Top" 然后将此属性添加到您的菜单元素: DockPanel.Dock="Top"

Make sure you explicitly save and re-compile your application after making XAML changes. 确保在更改XAML之后明确保存并重新编译应用程序。

I've personally had a lot of instances where XAML changes simply did not show up when debugging an application. 我个人有很多实例,其中在调试应用程序时根本不会显示XAML更改。 To be sure your changes are going through, you can clean the solution and rebuild. 为确保您的更改正在执行,您可以清理解决方案并重新构建。

我发现了一个导致问题的技术问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM