首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >禁用SwipeView滑动选项

禁用SwipeView滑动选项
EN

Stack Overflow用户
提问于 2021-02-23 23:35:27
回答 1查看 284关注 0票数 1

我在我的项目中使用SwipeView来显示和隐藏页面左侧的侧边菜单。现在我想通过点击按钮而不是滑动页面来打开和隐藏菜单。到目前为止,我想出了如何打开和隐藏菜单,甚至通过点击按钮,但我没有找到解决方案,我如何禁用滑动打开菜单。

你知道我怎样才能以正确的方式去做吗?

这是我用来实现滑动和轻敲效果的代码。

这是xaml.cs中的代码:

代码语言:javascript
复制
private async void OpenAnimation()
{
     await swipeContent.ScaleYTo(0.9, 300, Easing.SinOut);
}

private async void CloseAnimation()
{
     await swipeContent.RotateTo(0, 300, Easing.SinOut);
}

private void OpenSwipe(object sender, EventArgs e)
{
     MainSwipeView.Open(OpenSwipeItem.LeftItems);
     OpenAnimation();
}

private void CloseSwipe(object sender, EventArgs e)
{
     MainSwipeView.Close();
     CloseAnimation();
}

private void SwipeStarted(object sender, SwipeStartedEventArgs e)
{
     OpenAnimation();
}

private void SwipeEnded(object sender, SwipeEndedEventArgs e)
{
     if (!e.IsOpen)
         CloseAnimation();
}

这是xaml中的代码

代码语言:javascript
复制
<SwipeView x:Name="MainSwipeView" BackgroundColor="Transparent"
                       SwipeStarted="SwipeStarted" SwipeEnded="SwipeEnded">

谢谢。

EN

回答 1

Stack Overflow用户

发布于 2021-03-03 17:25:20

可以将IsEnabled属性设置为false以禁用卷帘。

xaml:

代码语言:javascript
复制
  <StackLayout HorizontalOptions="Center" VerticalOptions="CenterAndExpand">
        <SwipeView IsEnabled="False">
            <SwipeView.LeftItems>
                <SwipeItems>
                    <SwipeItem
                        BackgroundColor="LightGreen"
                        IconImageSource="grapes_24.png"
                        Invoked="Favorite_Invoked"
                        Text="Favorite" />
                    <SwipeItem
                        BackgroundColor="LightPink"
                        IconImageSource="star_small.png"
                        Invoked="Delete_Invoked"
                        Text="Delete" />
                </SwipeItems>
            </SwipeView.LeftItems>

            <Grid
                BackgroundColor="LightGray"
                HeightRequest="60"
                WidthRequest="300">
                <Label
                    HorizontalOptions="Center"
                    Text="Swipe right"
                    VerticalOptions="Center" />

            </Grid>
        </SwipeView>
    </StackLayout>

之前:https://imgur.com/vKDpplO

之后:https://imgur.com/0jPDRB3

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66336201

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档