微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Xamarin Forms Designer需要在地图顶部并排放置2个按钮

如何解决Xamarin Forms Designer需要在地图顶部并排放置2个按钮

目前,我将这两个按钮彼此重叠

不幸的是,Visual Studio不支持Xamarin中的可视化编辑,因此我必须手动编辑XAML代码,这很难做到

有人可以帮我弄清楚如何使这2个按钮并排而不是彼此重叠

<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" 
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="clr-namespace:Customrenderer;assembly=Customrenderer"
             x:Class="Customrenderer.MapPage">
    <StackLayout Margin="0,0">
        <Button Text="Add items" Clicked="OnAddItemsClicked"/>
        <Button Text="Add other" Clicked="OnAddOtherClicked"/>
        <local:CustomMap x:Name="customMap"
                     MapType="Street" />
    </StackLayout>
</ContentPage>

enter image description here

解决方法

使用嵌套的水平StackLayout

<StackLayout Margin="0,0">
    <StackLayout Orientaion="Horizontal">
      <Button Text="Add items" Clicked="OnAddItemsClicked"/>
      <Button Text="Add other" Clicked="OnAddOtherClicked"/>
    </StackLayout>
    <local:CustomMap x:Name="customMap"
                 MapType="Street" />
</StackLayout>

Grid

<Grid ColumnDefinitions="1*,1*" RowDefinitions="1*,Auto">
    <Button Grid.Row="0" Grid.Column="0" Text="Add items" Clicked="OnAddItemsClicked"/>
    <Button Grid.Row="0" Grid.Column="1" Text="Add other" Clicked="OnAddOtherClicked"/>
    <local:CustomMap x:Name="customMap" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" 
                 MapType="Street" />
</Grid>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。