欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

WPF使用DockPanel??棵姘宀季?/h1>
 更新時(shí)間:2022年02月25日 10:39:33   作者:.NET開發(fā)菜鳥  
這篇文章介紹了WPF使用DockPanel??棵姘宀季值姆椒?,文中通過示例代碼介紹的非常詳細(xì)。對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下

DockPanel:停靠面板

DockPanel定義一個(gè)區(qū)域,在此區(qū)域中,您可以使子元素通過描點(diǎn)的形式排列,這些對(duì)象位于 Children 屬性中。停靠面板類似于WinForm中控件的Dock屬性。DockPanel會(huì)對(duì)每個(gè)子元素進(jìn)行排序,并將根據(jù)指定的邊進(jìn)行停靠,多個(gè)??吭谕瑐?cè)的元素則按順序排序。在DockPanel中,指定??窟叺目丶?,會(huì)根據(jù)定義的順序占領(lǐng)邊角,所有控件絕不會(huì)交疊。

默認(rèn)情況下,后添加的元素只能使用剩余空間,無論對(duì)DockPanel的最后一個(gè)子元素設(shè)置任何??恐?,該子元素都將始終填滿剩余的空間。如果不希望最后一個(gè)元素填充剩余區(qū)域,可以將DockPanel屬性LastChildFill設(shè)置為false,還必須為最后一個(gè)子元素顯式指定停靠方向。

1、填充整個(gè)剩余空間

使用XAML代碼實(shí)現(xiàn):

<Window x:Class="WpfDemo.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="DockPanel面板" Height="237" Width="525" WindowStartupLocation="CenterScreen">
    <DockPanel>
        <Button DockPanel.Dock="Left" Content="ButtonLeft"></Button>
        <Button DockPanel.Dock="Top" Content="ButtonTop"></Button>
        <Button DockPanel.Dock="Right" Content="ButtonRight"></Button>
        <Button DockPanel.Dock="Bottom" Content="ButtonBottom"></Button>
        <Button  Content="ButtonTop"></Button>
    </DockPanel>
</Window>

2、最后元素不填充剩余空間

使用XAML代碼實(shí)現(xiàn):

<Window x:Class="WpfDemo.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="DockPanel面板" Height="237" Width="525" WindowStartupLocation="CenterScreen">
    <DockPanel LastChildFill="False">
        <Button DockPanel.Dock="Left" Content="ButtonLeft"></Button>
        <Button DockPanel.Dock="Top" Content="ButtonTop"></Button>
        <Button DockPanel.Dock="Right" Content="ButtonRight"></Button>
        <Button DockPanel.Dock="Bottom" Content="ButtonBottom"></Button>
        <Button  DockPanel.Dock="Top" Content="最后一個(gè)Button不填充剩余空間"></Button>
    </DockPanel>
</Window>

到此這篇關(guān)于WPF使用DockPanel??棵姘宀季值奈恼戮徒榻B到這了。希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論