欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

WPF(Grid与布局)

程序员文章站 2022-03-30 17:50:33

<window x:class="testofgridlayout.mainwindow" 
        xmlns="https://schemas.microsoft.com/winfx/2006/xaml/presentation" 
        xmlns:x="https://schemas.microsoft.com/winfx/2006/xaml" 
        title="留言板" height="240" width="400" 
        minheight="200" maxheight="300" minwidth="350" maxwidth="600"> 
    <grid margin="10"> 
        <grid.columndefinitions> 
            <columndefinition width="auto" minwidth="120"/> 
            <columndefinition width="*"/> 
            <columndefinition width="80"/> 
            <columndefinition width="4" /> 
            <columndefinition width="80"/> 
        </grid.columndefinitions> 
        <grid.rowdefinitions> 
            <rowdefinition height="25"/> 
            <rowdefinition height="4" /> 
            <rowdefinition height="*" /> 
            <rowdefinition height="4" /> 
            <rowdefinition height="25"/> 
        </grid.rowdefinitions> 
         
        <textblock text="请选择您的部门并留言: " grid.column="0" grid.row="0" verticalalignment="center" /> 
        <combobox grid.column="1" grid.row="0" grid.columnspan="4" borderbrush="black" /> 
        <textbox grid.column="0" grid.row="2" grid.columnspan="5" borderbrush="black" /> 
        <button content="提交" grid.column="2" grid.row="4" /> 
        <button content="清除" grid.column="5" grid.row="4" /> 
    </grid> 
</window> 

<window x:class="testofgridlayout.mainwindow"
        xmlns="https://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="https://schemas.microsoft.com/winfx/2006/xaml"
        title="留言板" height="240" width="400"
        minheight="200" maxheight="300" minwidth="350" maxwidth="600">
    <grid margin="10">
        <grid.columndefinitions>
            <columndefinition width="auto" minwidth="120"/>
            <columndefinition width="*"/>
            <columndefinition width="80"/>
            <columndefinition width="4" />
            <columndefinition width="80"/>
        </grid.columndefinitions>
        <grid.rowdefinitions>
            <rowdefinition height="25"/>
            <rowdefinition height="4" />
            <rowdefinition height="*" />
            <rowdefinition height="4" />
            <rowdefinition height="25"/>
        </grid.rowdefinitions>
       
        <textblock text="请选择您的部门并留言: " grid.column="0" grid.row="0" verticalalignment="center" />
        <combobox grid.column="1" grid.row="0" grid.columnspan="4" borderbrush="black" />
        <textbox grid.column="0" grid.row="2" grid.columnspan="5" borderbrush="black" />
        <button content="提交" grid.column="2" grid.row="4" />
        <button content="清除" grid.column="5" grid.row="4" />
    </grid>
</window>

[html] view plaincopyprint?
<window x:class="testofgrid.mainwindow" 
        xmlns="https://schemas.microsoft.com/winfx/2006/xaml/presentation" 
        xmlns:x="https://schemas.microsoft.com/winfx/2006/xaml" 
        title="mainwindow" height="350" width="525" loaded="window_loaded"> 
    <grid x:name="gridmain"> 
        <grid.columndefinitions > 
            <columndefinition /> 
            <columndefinition /> 
            <columndefinition /> 
        </grid.columndefinitions> 
         
        <grid.rowdefinitions > 
            <rowdefinition height="30px"/> 
            <rowdefinition height="30"/> 
            <rowdefinition height="0.5in"/> 
            <rowdefinition height="1cm"/> 
            <rowdefinition height="30pt"/> 
        </grid.rowdefinitions> 
    </grid> 
</window> 

<window x:class="testofgrid.mainwindow"
        xmlns="https://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="https://schemas.microsoft.com/winfx/2006/xaml"
        title="mainwindow" height="350" width="525" loaded="window_loaded">
    <grid x:name="gridmain">
        <grid.columndefinitions >
            <columndefinition />
            <columndefinition />
            <columndefinition />
        </grid.columndefinitions>
       
        <grid.rowdefinitions >
            <rowdefinition height="30px"/>
            <rowdefinition height="30"/>
            <rowdefinition height="0.5in"/>
            <rowdefinition height="1cm"/>
            <rowdefinition height="30pt"/>
        </grid.rowdefinitions>
    </grid>
</window>