簡體   English   中英

用於在Xamarin Forms中的AbsoluteLayout.LayoutBounds中綁定x和y坐標的數據類型

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM