日期:2014-05-17  浏览次数:20789 次

WPF实现 windows自带计算机 布局

 

<Window x:Class="OACt_WPFClient.布局的练习"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="计算器" Icon="IMG/App.ico"  Height="350" Width="270">
    <Grid>
        <Grid>
            <Menu   HorizontalAlignment="Stretch" VerticalAlignment="Top" FontSize="13">
                <MenuItem Header="查看(V)"></MenuItem>
                <MenuItem Header="编辑(E)"></MenuItem>
                <MenuItem Header="帮助(H)"></MenuItem>
                
            </Menu>
            <TextBox VerticalAlignment="Top" HorizontalAlignment="Stretch"  Margin="10,30,10,10" Height="45" BorderBrush="GreenYellow"  ></TextBox>
            <Grid Margin="10,80,10,10" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition></ColumnDefinition>
                    <ColumnDefinition></ColumnDefinition>
                    <ColumnDefinition></ColumnDefinition>
                    <ColumnDefinition></ColumnDefinition>
                    <ColumnDefinition></ColumnDefinition>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition></RowDefinition>
                    <RowDefinition></RowDefinition>
                    <RowDefinition></RowDefinition>
                    <RowDefinition></RowDefinition>
                    <RowDefinition></RowDefinition>
                    <RowDefinition></RowDefinition>
                </Grid.RowDefinitions>
                
                <Button Content="MC" Margin="4" Grid.Column="0" Grid.Row="0"></Button>
                <Button Content="MR" Margin="4" Grid.Column="1" Grid.Row="0"></Button>
                <Button Content="MS" Margin="4" Grid.Column="2" Grid.Row="0"></Button>
                <Button Content="M+" Margin="4" Grid.Column="3" Grid.Row="0"></Button>
                <Button Content="M-" Margin="4" Grid.Column="4" Grid.Row="0"></Button>
               
                <Button Content="-" Margin="4" Grid.Column="0" Grid.Row="1"></Button>
                <Button Content="CE" Margin="4" Grid.Column="1" Grid.Row="1"></Button>
                <Button Content="C" Margin="4" Grid.Column="2" Grid.Row="1"></Button>
                <Grid Margin="4" Grid.Column="3" Grid.Row="1">
                <Button >
                        <Button.Content>
                            <StackPanel>
                                <Label Content="-"   Margin="2,2,0,0"  Height="20" ></Label>
                                <Label Content="+" Margin="0,-28,0,0"  Height="20"></Label>
                           
                                </StackPanel>
                        </Button.Content>
                    </Button>
                
                </Grid>