Xamarin中VisualElement的X和Y的确切位置是什么?

fkvaft9z  于 2022-12-07  发布在  其他
关注(0)|答案(1)|浏览(118)

The official Xamarin document describes the X/Y property as The X/Y position of this element relative to its parents bounds. But it didn't clarify which position of the visual element if it's quite big.
Say I have a Frame element that looks like this. Is the Frame.X and Frame.Y going to be (X1,Y1), (X2,Y2) or neither?

eulz3vhy

eulz3vhy1#

你可以参考我试过的代码:

<StackLayout BackgroundColor="Black" HeightRequest="1000" WidthRequest="1000">
        <Frame BackgroundColor="White">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="100"/>
                <RowDefinition Height="100"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="100"/>
                <ColumnDefinition Width="100"/>
            </Grid.ColumnDefinitions>
            <BoxView Color="Red" />
            <BoxView Grid.Row="1"
                 Color="Teal" />        
            <BoxView Grid.Row="1"
                 Grid.Column="1"
                 Color="Purple" />
        </Grid>
        </Frame>
</StackLayout>

如果没有明确位置,它将从父容器的左上角开始布局。

相关问题