本文介绍了Xamarin.Forms 中的分隔符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在表单中使用水平分隔符.据我所知,Xamarin.Forms 没有提供.
I'd like to use horizontal separator lines in a form. As far as I found out, Xamarin.Forms doesn't provide one.
有人可以提供分隔符的片段吗?
Could someone provide a snippet for separators?
更新 1
根据 Jason 的提议,这看起来不错:
According to Jason's proposal, this looks fine:
// draws a separator line and space of 5 above and below the separator
new BoxView() { Color = Color.White, HeightRequest = 5 },
new BoxView() { Color = Color.Gray, HeightRequest = 1, Opacity = 0.5 },
new BoxView() { Color = Color.White, HeightRequest = 5 },
呈现下面的分隔线:
推荐答案
您可以尝试使用 BoxView
// sl is a StackLayout
sl.Children.Add(new BoxView() { Color = Color.Black, WidthRequest = 100, HeightRequest = 2 });
虽然在我的测试中,没有遵循宽度请求.这可能是一个错误,或者其他设置可能会干扰它.
although in my test, the width request is not being followed. This may be a bug, or other settings might be interfering with it.
这篇关于Xamarin.Forms 中的分隔符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!