Xamarin.Forms Slider iOS gesture failure

∥☆過路亽.° 提交于 2019-12-12 01:28:22

问题


When I try to use the Slider on iOS it slides out the Master menu. It works fine on Android.

One option would be to disable gestures all together but I haven't found a way to disable them for only that page. I would very much like to keep the sliding gestures for the other pages without sliders.


回答1:


It sounds like your slider may be too close to edge of the page. If your design allows it, try adding a margin to the left and right of the slider.

<?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:SliderTest"
             x:Class="SliderTest.MainPage">
   <StackLayout Orientation="Vertical" VerticalOptions="Center">
     <Slider Margin="10,0,10,0"/>
   </StackLayout>
</ContentPage>

And in case you need separate margins for iOS and Android, you can do that like this:

  <StackLayout Orientation="Vertical" VerticalOptions="Center">
    <Slider>
      <Slider.Margin>
        <OnPlatform x:TypeArguments="Thickness" iOS="10,0,10,0" Android="20,0,20,0"/>
      </Slider.Margin>
    </Slider>
  </StackLayout>


来源:https://stackoverflow.com/questions/38432446/xamarin-forms-slider-ios-gesture-failure

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!