我在我的项目中使用SwipeView来显示和隐藏页面左侧的侧边菜单。现在我想通过点击按钮而不是滑动页面来打开和隐藏菜单。到目前为止,我想出了如何打开和隐藏菜单,甚至通过点击按钮,但我没有找到解决方案,我如何禁用滑动打开菜单。
你知道我怎样才能以正确的方式去做吗?
这是我用来实现滑动和轻敲效果的代码。
这是xaml.cs中的代码:
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中的代码
<SwipeView x:Name="MainSwipeView" BackgroundColor="Transparent"
SwipeStarted="SwipeStarted" SwipeEnded="SwipeEnded">谢谢。
发布于 2021-03-03 17:25:20
可以将IsEnabled属性设置为false以禁用卷帘。
xaml:
<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://stackoverflow.com/questions/66336201
复制相似问题