.NET MAUI 设置单独的边框宽度?

.NET MAUI Set individual border widths?

使用 CSS,您可以设置 border-left-widthborder-right-width 等以获得边框的单独宽度。

在 .NET MAUI 中是否可能有等效项,如果可以,您是怎么做到的?

我知道 Border 元素,但它只有一个 StrokeWidth

边框元素无法做到这一点,因为它旨在呈现笔画,可能带有圆角和破折号。

ContentViewBackgroundColorPadding 结合使用。

这是 Maui dotnet bot,每边都有不同厚度的填充(边框):

    <ContentView BackgroundColor="Gray">
        <ContentView BackgroundColor="HotPink" Padding="1,2,3,4" VerticalOptions="Center" HorizontalOptions="Center">
            <VerticalStackLayout BackgroundColor="LightPink" Spacing="25" Padding="30,0" VerticalOptions="Center" HorizontalOptions="Center">
                <Image Source="dotnet_bot.png" HeightRequest="100" HorizontalOptions="Center" />
                <Button x:Name="CounterBtn" Text="Click me" SemanticProperties.Hint="Counts the number of times you click" Clicked="OnCounterClicked" HorizontalOptions="Center" />
            </VerticalStackLayout>
        </ContentView>
    </ContentView>