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



使用CSS,您可以设置border-left-width,border-right-width等来获得您的边框的个人宽度。

在。net MAUI中是否可能实现相同的功能,如果可以,如何实现?

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

Border元素不能这样做,因为它被设计为呈现笔触,可能是圆角和虚线。

使用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>

最新更新