c# - 使用自定义渲染器 UWP 打开 SwipeView
问题描述
几天以来,我一直在尝试寻找一种方法来引发滑动,使用鼠标打开 Xamarin Forms SwipeView。我在这里找到了图片中的解决方案,至少我有事件发生并且解释是正确的。问题是我有控制台消息,但它不会打开。我做了界面,Asbstract 基类,没有任何东西可以让我打开滑动。有人有想法吗?[程序集:ExportRenderer(typeof(SwipeView), typeof(SwipeViewRendererUWP))]
public class SwipeViewRendererUWP : SwipeViewRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<SwipeView> e)
{
base.OnElementChanged(e);
if (Control != null)
{
Control.ManipulationMode = ManipulationModes.TranslateX | ManipulationModes.TranslateInertia;
Control.ManipulationDelta += Control_ManipulationDelta;
Control.ManipulationCompleted += Control_ManipulationCompleted;
Control.ManipulationStarted += Control_ManipulationStarted;
Control.PointerPressed += Control_PointerPressed;
Control.PointerReleased += Control_PointerReleased;
}
}
private void Control_ManipulationStarted(object sender, ManipulationStartedRoutedEventArgs e)
{
}
private void Control_PointerReleased(object sender, PointerRoutedEventArgs e)
{
ReleasePointerCaptures();
}
private void Control_PointerPressed(object sender, PointerRoutedEventArgs e)
{
CapturePointer(e.Pointer);
}
private bool _isSwiped;
private void Control_ManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e)
{
Server.ConsoleDebug("Swipe Ended");
_isSwiped = false;
}
private void Control_ManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
{
if (e.IsInertial && !_isSwiped)
{
var swipedDistance = e.Cumulative.Translation.X;
if (Math.Abs(swipedDistance) <= 2) return;
{
if (swipedDistance > 0)
{
Element.Open(OpenSwipeItem.LeftItems);
Server.ConsoleDebug("left swipe");
}
else
{
Element.Open(OpenSwipeItem.RightItems);
Server.ConsoleDebug("right swipe");
}
_isSwiped = true;
}
}
}
}
解决方案
推荐阅读
- ios - UIView(放置在滚动视图内)在以编程方式更改高度常数时不显示其子视图
- neural-network - 将 ANN 拟合到函数的反向传播错误
- arrays - 编译器在数组末尾输出 0
- php - 在 Woocommerce 中以编程方式添加新产品类别
- jenkins - Jenkins 声明性管道作为代码脚本错误
- python - 获取“AttributeError:'Rolling'对象没有属性'astype'”
- javascript - 将嵌套数组 -> 数组 -> 对象转换为数组 -> 对象 => 对象值:对象值
- aruco - 找到 aruco 标记的中心
- javascript - Barba.js + 鼠标滚轮 + TweenMax。我不明白为什么页面滚动不起作用
- sql - 重命名一个查询中具有依赖关系的 SQL Server 表