首页 > 其他分享 >wpf基本布局控件 -- 01

wpf基本布局控件 -- 01

时间:2023-07-05 23:34:40浏览次数:41  
标签:控件 01 -- 布局 页面设置 wpf

<Window x:Class="WpfApp1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WpfApp1"
        mc:Ignorable="d"
        Title="wdpf入门学习" Height="450" Width="800">
    <Grid x:Name="___No_Name_asdasdas">
        <!-- 布局选项 二行两列  -->
        <Grid.RowDefinitions>
            <!-- height属性高度 auto 自适应 根据子元素是否可以撑开 或者固定像素 eg:100
            或 比列 2 * 标识是第二行高度的2倍
            width 和 height 类似
            -->
            <RowDefinition  />
            <RowDefinition />
        </Grid.RowDefinitions>

        <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>

        <!-- 样式的设置
            Grid.ColumnSpan="2" 占据 2 列的位置
        <Border Background="red" Grid.ColumnSpan="2" Grid.RowSpan="2" />
        给整个页面设置ref背景色
        -->
        <Border Background="red" Grid.ColumnSpan="2" Grid.RowSpan="2" />
        <Border  Grid.Column="1" Grid.Row="0"  Background="yellow"  />
        <Border  Grid.Column="0" Grid.Row="1" Background="pink" />
        <Border Grid.Column="1" Grid.Row="1"  Background="skyblue"  />

        <!-- StackPanel 布局控件 水平或者垂直放置元素
         默认是垂放置元素的 vertical 是默认垂直排列
        Orientation 设置方向  Horizontal 是水平排列
        -->
         <StackPanel Orientation="Horizontal">
            <Button Width="100" Height="40" Background="yellow" />
            <Button Width="100" Height="40" Background="yellow" />
            <Button Width="100" Height="40" Background="yellow" />
            <Button Width="100" Height="40" Background="yellow" />
            <Button Width="100" Height="40" Background="yellow" />
            <Button Width="100" Height="40" Background="yellow" />
            <Button Width="100" Height="40" Background="yellow" />
            <Button Width="100" Height="40" Background="yellow" />
            <Button Width="100" Height="40" Background="yellow" />
            <Button Width="100" Height="40" Background="yellow" />
        </StackPanel>
        <!-- WrapPanel 环绕控件 当水平或垂直空间不够会自动换行
        Orientation 默认水平排列 Horization 
        Vertiavl 垂直排列
        -->
        <WrapPanel  Grid.Row="1" Grid.Column="0" Orientation="Vertical">
            <Button Width="100" Height="40" />
            <Button Width="100" Height="40" />
            <Button Width="100" Height="40" />
            <Button Width="100" Height="40" />
            <Button Width="100" Height="40" />
            <Button Width="100" Height="40" />
            <Button Width="100" Height="40" />
            <Button Width="100" Height="40" />
            <Button Width="100" Height="40" />
        </WrapPanel>
        <!-- 
         停靠面板
          最后一个元素默认可以填充{拉伸}剩余所有的空间
        LastChildFill = false 设置不填充
        DockPanel.Dock 设置元素的方向
        
        -->
        <DockPanel Grid.Row="1" Grid.Column="1" LastChildFill="true">
            <Button DockPanel.Dock="Bottom" Width="100" Height="40" Background="hotpink" />
            <Button DockPanel.Dock="top" Width="100" Height="40" Background="hotpink" />
            <Button Width="100" Height="40" Background="hotpink" />
        </DockPanel>
        <!-- 平均布局
        
        -->
        <UniformGrid  Grid.Row="0" Grid.Column="1">
            <Button Width="100" Height="30" />
            <Button Width="100" Height="30" />
            <Button Width="100" Height="30" />
            <Button Width="100" Height="30" />
            <Button Width="100" Height="30" />
            <Button Width="100" Height="30" />
        </UniformGrid>
    </Grid>
</Window>

 

标签:控件,01,--,布局,页面设置,wpf
From: https://www.cnblogs.com/zhulongxu/p/17530614.html

相关文章

  • es笔记三之term,match,match_phrase 等查询方法介绍
    本文首发于公众号:Hunter后端原文链接:es笔记三之term,match,match_phrase等查询方法介绍首先介绍一下在es里有两种存储字符串的字段类型,一个是keyword,一个是text。keyword在存储数据的时候是作为一个整体存储的,不会对其进行分词处理text存储数据的时候会对字符串进行分......
  • HTML&CSS
    HTMLHTML是一门语言,所有的网页都是用HTML这门语言编写出来的HTML(HyperTextMarkupLanguage):超文本标记语言 超文本:超越了文本的限制,比普通文本更强大。除了文字信息,还可以定义图片、音频、视频等内容 标记语言:由标签构成的语言HTML运行在浏览器上,HTML标签由浏览器......
  • 第五周
    packagetest;publicclassass{publicstaticvoidmain(String[]args){//TODOAuto-generatedmethodstubinta=1;intsum=0; while(a<100){if(a%3==0)sum+=a;a++;}System.out.println(sum);}}  intsum=0;for(inta=0;a<100;a+=3){sum+=a;}......
  • 新增接口&页面布局
    1.新增1.1.新增接口1.2.观察前端页面我们需要在前端弄一个增加的对话框给新增的按钮绑定openEditUI方法效果(感觉右边太窄了)其他:......
  • 第六周
    packagetest;1、使用for循环计算1-100的和,除了以3结尾的那些数importjava.util.Scanner;publicclassacc{publicstaticvoidmain(String[]args){//TODOAuto-generatedmethodstubintsum=0;for(inti=1;i<=100;i++){......
  • 2023.0705 学习记录(递归,var,foreach,Array)
    递归1.做一个累乘的递归代码:publicstaticintmultiplications(inta){if(a==1){return1;}returna*multiplications(a-1);}2.做一个1-2+3-4..递归pub......
  • java进阶3:GC 的背景与一般原理
    为什么会有GC其最本质的原因是因为内存资源的稀缺性。我们计算机最核心的资源是CPU和内存,CPU是随着计算机一直存在的东西,核数有限但是一直存在;但内存比较稀缺,A占满了,B就不能用了,我们怎么可以共享使用这个内存呢,这就是GC产生的原因了。背景:在传统的编程语言中,程序员需要手动分配和释......
  • mysql版本升级,升级成为8.0.32
    一、升级的方式和注意事项 1、同版本升级 简称本地升级 高版本数据库挂载低版本数据库数据实现升级2、升级注意事项  备份关键数据库文件 备份指定数据库的指定表数据二、部署Mysql5.6数据库,在Mysql5.6创建数据库名字data,创建表student设计表结构,插入个人记录和两条......
  • 本地yum仓库脚本
    #编写搭建本地yum仓库脚本[root@localhost~]#vimyum.sh #!/bin/bashecho"正在配置本地yum仓库..."mkdir/mnt/centosmount/dev/cdrom/mnt/centos&>/dev/nullecho'/dev/cdrom/mnt/centosiso9660defaults00'>>/etc/fstabmount-arm-rf......
  • 六月学习之Haproxy高级功能(一)
    6、Haproxy高级功能6.1、基于cockie会话保持在backend服务器组启用cookie植入功能haproxy会将后端服务器定义的serverID植入到客户端的cookie中,以保持会话的持久性,需要设置backend中的cookie以及server指定的cookie选项6.1.1、配置示例1、配置haproxy基于cookie实现会话绑定#mai......