[英]Data type for binding x and y coordinates in AbsoluteLayout.LayoutBounds in Xamarin Forms
我有一个包含身体部位细节的数据数组,我正在使用绝对布局。 我只需要提供X和Y坐标,但我不想提供应该自动采取的宽度和高度。
所以,问题是,如果我们需要绑定X和Y坐标,那么DATA TYPE应该是什么。 我正在使用列表视图来绑定所有这些数据。 例如。
AbsoluteLayout.LayoutBounds =“0.80,0.193”
AbsoluteLayout.LayoutBounds =“0.4,0.21”
使用位置比例时,可以自动调整宽度和高度。
AbsoluteLayout.LayoutBounds="0.4,0.21,-1,-1"
您可以绑定LayoutBounds
,如下所示:
<ListView x:Name="EmployeeView" >
<ListView.ItemTemplate>
<DataTemplate>
<AbsoluteLayout>
<Label Text="I'm centered on iPhone 4 but no other device"
AbsoluteLayout.LayoutBounds="{Binding rect1}" LineBreakMode="WordWrap" />
<Label Text="I'm bottom center on every device."
AbsoluteLayout.LayoutBounds="{Binding rect2}" AbsoluteLayout.LayoutFlags="All"
LineBreakMode="WordWrap" />
</AbsoluteLayout>
</DataTemplate>
</ListView>
并且Bindable属性应该是Xamarin.Forms.Rectangle
double x,y,width,height;
x= 100;
y=100;
width = 100;
height = 100;
Xamarin.Forms.Rectangle rect = new Xamarin.Forms.Rectangle(x,y,width,height);
Employees employees = new Employees();
employees.rect = rect;
EmployeeView.ItemsSource = employees;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.