开发者

What is the accepted way to get a main window with menubar and toolbar in WPF?

开发者 https://www.devze.com 2023-01-30 12:34 出处:网络
I\'m creating a WPF application, as a foray into WPF, and I\'m a bit stuck on how to start. What is the \'standard\' way to create a main application window with a menubar at the top, and a button bar

I'm creating a WPF application, as a foray into WPF, and I'm a bit stuck on how to start. What is the 'standard' way to create a main application window with a menubar at the top, and a button bar right below it, then a big open space where m开发者_如何学编程y app goes? Is it a StackPanel, Canvas, Grid, placed directly on the Window...? How do I get started?


I would prefer to a Grid with a Menu and a Toolbar like this:

<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        x:Name="self"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Menu Grid.Row="0">
            <MenuItem Header="File">
                <MenuItem Header="Open" />
                <MenuItem Header="Close" />
            </MenuItem>
        </Menu>
        <ToolBar Grid.Row="1">
            <Button Content="Foo" />
            <Button Content="Bar" />
        </ToolBar>
    </Grid>
</Window>
0

精彩评论

暂无评论...
验证码 换一张
取 消