XAML中的菜单栏不再像WINFORM一样有一个专用的控件来实现它,我们通过DockPanel来实现这样的一个功能。

<Window x:Class="MaterialStorage.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="20"></RowDefinition>
            <RowDefinition Height="*"></RowDefinition>
            <RowDefinition Height="20"></RowDefinition>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" ></ColumnDefinition>
        </Grid.ColumnDefinitions>
        <DockPanel Grid.Row="0" Grid.Column="1" Height="20" HorizontalAlignment="Stretch" Name="dockPanel1" Margin="0" VerticalAlignment="Top">
            <Menu Name="menu1" Width="Auto" DockPanel.Dock="Top"
VerticalAlignment="Center"  >
                <MenuItem Header="文件">
                    <MenuItem Header="报表导出" Name="newMember" />
                    <MenuItem Header="数据备份" Name="saveMember" />
                    <Separator/>
                    <MenuItem Header="关闭" Name="exit"  Click="Exit_Click" />
                </MenuItem>
                <MenuItem Header="关于" Click="About_Click"  />
            </Menu>
        </DockPanel>
        <Grid Grid.Row="1" Grid.Column="1" Background="Beige">
            <Grid.RowDefinitions>
                <RowDefinition Height="40*"></RowDefinition>
                <RowDefinition Height="40*"></RowDefinition>
                <RowDefinition Height="20*"></RowDefinition>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" ></ColumnDefinition>
            </Grid.ColumnDefinitions>
            <Grid Grid.Row="0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="25*" ></ColumnDefinition>
                    <ColumnDefinition Width="75*" ></ColumnDefinition>
                </Grid.ColumnDefinitions>
                <StackPanel Grid.Column="0" Grid.Row="0" VerticalAlignment="Center">
                    <TextBlock Padding="10,0,0,0">领取物料:</TextBlock>
                </StackPanel>
                <WrapPanel Name="Materials" HorizontalAlignment="Left" Grid.Column="1" Grid.Row="0">
                    
                </WrapPanel>
            </Grid>
            <Grid Grid.Row="1">
                <Grid.RowDefinitions>
                    <RowDefinition Height="3"></RowDefinition>
                    <RowDefinition Height="*"></RowDefinition>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="25*" ></ColumnDefinition>
                    <ColumnDefinition Width="75*" ></ColumnDefinition>
                </Grid.ColumnDefinitions>
                <Line Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2" Name="barLine1" Stroke="BurlyWood" StrokeThickness="3" VerticalAlignment="Top"></Line>
                <WrapPanel Grid.Row="1" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Left">
                    <TextBlock Padding="10,0,0,0" VerticalAlignment="Center">领取数量:</TextBlock>
                    <TextBox Name="MaterialQuantity" Grid.Column="1" Width="50" Height="20" VerticalAlignment="Center"></TextBox>
                </WrapPanel>
                <WrapPanel Grid.Row="1" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Left">
                    <TextBlock Padding="10,0,0,0" VerticalAlignment="Center">领取人:</TextBlock>
                    <WrapPanel Name="Picker" HorizontalAlignment="Left" Grid.Column="1" Grid.Row="0">

                    </WrapPanel>
                </WrapPanel>
            </Grid>
            <Grid Grid.Row="2">
                <Grid.RowDefinitions>
                    <RowDefinition Height="3"></RowDefinition>
                    <RowDefinition Height="*"></RowDefinition>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="25*" ></ColumnDefinition>
                    <ColumnDefinition Width="75*" ></ColumnDefinition>
                </Grid.ColumnDefinitions>
                <Line Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2" Name="barLine2" Stroke="BurlyWood" StrokeThickness="3" VerticalAlignment="Top"></Line>
                <WrapPanel Grid.Row="1" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Center">
                    <Button VerticalAlignment="Center" HorizontalAlignment="Center" Width="50" Click="Button1_Click">确定</Button>
                </WrapPanel>

            </Grid>
        </Grid>
        <DockPanel Grid.Row="2" Grid.Column="1"  Height="20" HorizontalAlignment="Stretch" Name="dockPanel2" Margin="0" VerticalAlignment="Bottom">
            <StatusBar Height="20" Name="statusBar1" Width="Auto" DockPanel.Dock="Top" VerticalAlignment="Center"   >
                <TextBlock Name="statusValue">fff</TextBlock>
            </StatusBar>
        </DockPanel>
    </Grid>
</Window>

我们看到在下面我放了一个状态栏来显示当前的状态。

posted on 2013-02-28 17:36  振宇爸爸  阅读(188)  评论(0编辑  收藏  举报