zoukankan      html  css  js  c++  java
  • wpf 计算器布局练习

    先看一下windows自带计算机的布局:


    大概布局能看出,有菜单栏(menu),有显示框(textbox),然后剩下的6行5列的布局

    先看下代码:

                <StackPanel>
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition></RowDefinition>
                        </Grid.RowDefinitions>
                        <TextBox Name="xianshi" Text="显示框" Height="50" Margin="5,5,5,5"></TextBox>
                    </Grid>
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition></RowDefinition>
                            <RowDefinition></RowDefinition>
                            <RowDefinition></RowDefinition>
                            <RowDefinition></RowDefinition>
                            <RowDefinition></RowDefinition>
                            <RowDefinition></RowDefinition>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition></ColumnDefinition>
                            <ColumnDefinition></ColumnDefinition>
                            <ColumnDefinition></ColumnDefinition>
                            <ColumnDefinition></ColumnDefinition>
                            <ColumnDefinition></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <Button Grid.Row="0" Grid.Column="0" Content="MC" Margin="5"></Button>
                        <Button Grid.Row="0" Grid.Column="1" Content="MR" Margin="5"></Button>
                        <Button Grid.Row="0" Grid.Column="2" Content="MS" Margin="5"></Button>
                        <Button Grid.Row="0" Grid.Column="3" Content="M+" Margin="5"></Button>
                        <Button Grid.Row="0" Grid.Column="4" Content="M-" Margin="5"></Button>
    
                        <Button Grid.Row="1" Grid.Column="0" Content="←" Margin="5"></Button>
                        <Button Grid.Row="1" Grid.Column="1" Content="CE" Margin="5"></Button>
                        <Button Grid.Row="1" Grid.Column="2" Content="C" Margin="5"></Button>
                        <Button Grid.Row="1" Grid.Column="3" Content="±" Margin="5"></Button>
                        <Button Grid.Row="1" Grid.Column="4" Content="√" Margin="5"></Button>
    
                        <Button Grid.Row="2" Grid.Column="0" Content="7" Margin="5"></Button>
                        <Button Grid.Row="2" Grid.Column="1" Content="8" Margin="5"></Button>
                        <Button Grid.Row="2" Grid.Column="2" Content="9" Margin="5"></Button>
                        <Button Grid.Row="2" Grid.Column="3" Content="/" Margin="5"></Button>
                        <Button Grid.Row="2" Grid.Column="4" Content="%" Margin="5"></Button>
    
                        <Button Grid.Row="3" Grid.Column="0" Content="4" Margin="5"></Button>
                        <Button Grid.Row="3" Grid.Column="1" Content="5" Margin="5"></Button>
                        <Button Grid.Row="3" Grid.Column="2" Content="6" Margin="5"></Button>
                        <Button Grid.Row="3" Grid.Column="3" Content="*" Margin="5"></Button>
                        <Button Grid.Row="3" Grid.Column="4" Content="1/x" Margin="5"></Button>
    
                        <Button Grid.Row="4" Grid.Column="0" Content="1" Margin="5"></Button>
                        <Button Grid.Row="4" Grid.Column="1" Content="2" Margin="5"></Button>
                        <Button Grid.Row="4" Grid.Column="2" Content="3" Margin="5"></Button>
                        <Button Grid.Row="4" Grid.Column="3" Content="-" Margin="5"></Button>
                        <Button Grid.Row="4" Grid.Column="4" Content="=" Grid.RowSpan="2" Margin="5"></Button>
    
                        <Button Grid.Row="5" Grid.Column="0" Content="0" Grid.ColumnSpan="2" Margin="5"></Button>
    
                        <Button Grid.Row="5" Grid.Column="2" Content="." Margin="5"></Button>
                        <Button Grid.Row="5" Grid.Column="3" Content="+" Margin="5"></Button>
                        
                    </Grid>
                </StackPanel>
            </DockPanel>

    看下生成的结果:


    虽然还差了点,但是继续努力吧。。。继续学习。。

  • 相关阅读:
    PHP中如何获取多个checkbox的值
    修改Netbeans默认使用UTF-8编码
    php用户注册
    windows环境下MySQL重启的命令行说明
    wampserver修改mysql数据库密码后phpMyAdmin无法连接数据库
    JavaScript判断闰年
    移动端300毫秒事件响应延迟解决方法[fastclick]
    移动端一像素边框解决方案[css scale]
    移动端禁止缩放<meta>
    数据结构概念
  • 原文地址:https://www.cnblogs.com/dyllove98/p/3233629.html
Copyright © 2011-2022 走看看