如果视图位于Xamarin.Forms.Map以下,则无法使用

问题描述 投票:0回答:1

所以基本上我想向堆栈布局中添加1个按钮,该按钮将位于Xamarin.Forms.Maps类型的视图的正下方,问题是,如果它位于地图下方,则无法与之交互如果地图在按钮的前面,但不是。如果我将其放在地图顶部,则该按钮可以正常工作。此问题适用于其他视图,例如标签。

这是一个错误,还是有任何属性会自动禁用与地图下方视图的交互?enter image description here

这是我认为的代码:

<ContentPage>
   <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="100*"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="100*"/>
            <RowDefinition Height="100*"/>
        </Grid.RowDefinitions>

        <Image
            Grid.Row="0"
            Grid.Column="0"
            Grid.RowSpan="2"

            Aspect="AspectFill"
            Source="{Binding Movie.TheImage}">
        </Image>
        <BoxView
            x:Name="FilterColor"

            Grid.Row="0"
            Grid.Column="0"
            Grid.RowSpan="2"

            Opacity="0.7">
         </BoxView>

        <StackLayout
            Margin="25">

            <Image
                x:Name="ReturnImage"

                    Source="ReturnInverted.png"

                    BackgroundColor="Transparent"
                    WidthRequest="30"
                    HeightRequest="30"

                    VerticalOptions="Start"
                    HorizontalOptions="Start">
                </Image>
            <Button
                    x:Name="ButtonReturn"

                    BackgroundColor="Transparent"
                    WidthRequest="30"
                    HeightRequest="30"

                    VerticalOptions="Start"
                    HorizontalOptions="Start"
                    Margin="0,-30,0,0"

                    Command="{Binding ReturnButton}">
                </Button>

            <Patch:Label
                    Text = "{Binding Movie.Title}"
                    TextColor="White"
                    FontSize="60"

                    MinFontSize="0"
                    AutoFit="Width"
                    Lines="1"
                    MaxLines="1"

                    HorizontalTextAlignment="Center"
                    VerticalOptions="Start"
                    HorizontalOptions="CenterAndExpand">
                </Patch:Label>
            <Patch:Label
                    Text="{Binding Movie.SubTitle}"
                    TextColor="White"

                    FontSize="60"
                    MinFontSize="0"
                    AutoFit="Width"
                    Lines="1"
                    MaxLines="1"

                    Margin="15,0,0,0"
                    HorizontalTextAlignment="Center"
                    VerticalOptions="Start"
                    HorizontalOptions="CenterAndExpand"
                ></Patch:Label>

            <Button
                    x:Name="Button_Details"

                    Text="Details"
                    TextColor="White"
                    FontSize="16"
                    FontAttributes="Bold"
                    WidthRequest="0"
                    HeightRequest="0"
                    CornerRadius="10"

                    BackgroundColor="LightGray"
                    VerticalOptions="Start"
                    HorizontalOptions="Start"

                    Command="{Binding GoTo_ElementDetails}">
                </Button>
            <Button
                    x:Name="Button_Location"

                    Text="Location"
                    TextColor="White"
                    FontSize="15"
                    FontAttributes="Bold"
                    WidthRequest="0"
                    HeightRequest="0"
                    CornerRadius="10"

                    BackgroundColor="Gray"
                    VerticalOptions="Start"
                    HorizontalOptions="EndAndExpand"
                    Margin="0">
                </Button>

            <map:Map
                x:Name="MyMap"

                MapType="Street"
                HasZoomEnabled="True"
                HasScrollEnabled="True"

                VerticalOptions="Center"
                HorizontalOptions="Center"
                HeightRequest="0"
                Margin="0,30,0,0">
                <map:Map.ItemTemplate>
                <DataTemplate>
                    <map:Pin Position="{Binding Position}"
                              Address="{Binding Address}"
                              Label="{Binding PlaceName}" />
                </DataTemplate>
            </map:Map.ItemTemplate>
            </map:Map>


            <Button
                x:Name="Button_GoToMap"

                Text="Open in App"
                TextColor="White"
                FontSize="20"
                FontAttributes="Bold"
                HeightRequest="0"
                WidthRequest="0"
                CornerRadius="15"

                BackgroundColor="Gray"
                VerticalOptions="Start"
                HorizontalOptions="CenterAndExpand"
                Margin="0,20,0,0"
                Clicked="Button_GoToMap_Clicked">
            </Button>

        </StackLayout>

    </Grid>

</ContentPage>

仅此而已,任何想法或建议都值得欢迎。如果您需要更多信息,我们将在收到您的请求后立即提供。谢谢大家的时间,希望您度过愉快的一天。

xaml xamarin xamarin.forms xamarin.android xamarin.ios
1个回答
0
投票

发生这种情况是Button的空间不足。将其包装在ScrollView的整个视图中,如果该按钮起作用,则可能必须通过设置HeightRequest和/或WidthRequest来控制其尺寸来缩小地图视图的尺寸。

© www.soinside.com 2019 - 2024. All rights reserved.