iT邦幫忙

2022 iThome 鐵人賽

DAY 10
0
Software Development

30天學習.Net MAUI系列 第 10

10.創建.NET MAUI Layout (三)

  • 分享至 

  • xImage
  •  

我們今天接著介紹HorizontalStackLayout和VericalStackLayout

HorizontalStackLayout

About

在水平堆疊中組織子檢視,而且是較高效能的StackLayout 替代方案。並且HorizontalStackLayout也可以做為包含其他子版面配置的父版面配置(巢狀)

我們練習HorizontalStackLayout

<HorizontalStackLayout Margin="10">
            <Label Text="Todo Item" 
                   VerticalOptions="Center" 
                   HorizontalOptions="Center" />
            <CheckBox />
        </HorizontalStackLayout>

我們打開TodoPage.xaml並修改

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="Todo.TodoPage"
             Title="TodoPage">
    <VerticalStackLayout Margin="10">
        <Label 
            Text="Welcome to .NET MAUI!"
            VerticalOptions="Center" 
            HorizontalOptions="Center" />
        <Button Text="Go to Add Page" Clicked="ButtonClicked"/>
        <HorizontalStackLayout Margin="10">
            <Label Text="Todo Item" 
                   VerticalOptions="Center" 
                   HorizontalOptions="Center" />
            <CheckBox />
        </HorizontalStackLayout>
        <HorizontalStackLayout Margin="10">
            <Label Text="Todo Item" 
                   VerticalOptions="Center" 
                   HorizontalOptions="Center" />
            <CheckBox />
        </HorizontalStackLayout>
        <HorizontalStackLayout Margin="10">
            <Label Text="Todo Item" 
                   VerticalOptions="Center" 
                   HorizontalOptions="Center" />
            <CheckBox />
        </HorizontalStackLayout>
    </VerticalStackLayout>
</ContentPage>

https://ithelp.ithome.com.tw/upload/images/20220925/20108931o50MhnBWFo.png

VericalStackLayout

About

在垂直堆疊中組織子檢視,而且是較高效能的 StackLayout 替代方案。並且VerticalStackLayout也可以當做包含其他子版面配置的父版面配置(巢狀)

<VerticalStackLayout Margin="10">
...
</VerticalStackLayout>

用上述例子

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="Todo.TodoPage"
             Title="TodoPage">
    <VerticalStackLayout Margin="10">
        <Label 
            Text="Welcome to .NET MAUI!"
            VerticalOptions="Center" 
            HorizontalOptions="Center" />
        <Button Text="Go to Add Page" Clicked="ButtonClicked"/>
        <HorizontalStackLayout Margin="10">
            <Label Text="Todo Item" 
                   VerticalOptions="Center" 
                   HorizontalOptions="Center" />
            <CheckBox />
        </HorizontalStackLayout>
        <HorizontalStackLayout Margin="10">
            <Label Text="Todo Item" 
                   VerticalOptions="Center" 
                   HorizontalOptions="Center" />
            <CheckBox />
        </HorizontalStackLayout>
        <HorizontalStackLayout Margin="10">
            <Label Text="Todo Item" 
                   VerticalOptions="Center" 
                   HorizontalOptions="Center" />
            <CheckBox />
        </HorizontalStackLayout>
    </VerticalStackLayout>
</ContentPage>

https://ithelp.ithome.com.tw/upload/images/20220925/20108931o50MhnBWFo.png


上一篇
9.創建.NET MAUI Layout (二)
下一篇
11.關於.NET MAUI Views(一)
系列文
30天學習.Net MAUI30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言