本文介绍了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

根据杰森的建议,这看起来不错:

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中的分隔符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 08:58