1

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 my app goes? Is it a StackPanel, Canvas, Grid, placed directly on the Window...? How do I get started?

thecoop
  • 45,220
  • 19
  • 132
  • 189

1 Answers1

2

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>
wickie79
  • 470
  • 1
  • 3
  • 7