不能将源代码用于已弃用的控件 SlidableListItem [英] Can't use source code for deprecated control SlidableListItem

查看:22
本文介绍了不能将源代码用于已弃用的控件 SlidableListItem的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Microsoft 已弃用 SlidableListItem 以支持 SwipeControl.我使用 XAML 控件库尝试了 SwipeControl - 它不允许我用鼠标左右滑动(我可以使用 SlidableListItem).我想我需要一个触摸屏设备才能工作.

因此,尽管已更新到最新的 nuget 软件包,我还是想继续使用 SlidableListItem.

我已将 SlidableListItem 的代码从 WindowsCommunityToolKit 分支 4.0.0 复制到我的项目中.当我尝试使用控件时出现此崩溃:

<块引用>

System.TypeLoadException: 加载 a 时发生故障键入.\r\n 在 Windows.UI.Xaml.FrameworkElement.MeasureOverride(Size可用大小)

(我昨天成功地将 HamburgerControl 的代码复制到我的项目中.)

解决方案

我试图复制 SlidableListItem,注意以下几点后,成功复制:

  1. 如果不需要SwipeControl,请删除相关代码:
    • 请勿复制SlidableListItemSwipeControlTemplate.xaml
    • 的代码
    • 删除SlidableListItem.cs中与UseSwipeControlWhenPossible相关的属性和回调方法(如OnUseSwipeControlWhenPossibleChangedOnSwipeControlValueChangedUpdateSwipeControlItems 等)
    • SledableListItem.cs文件中,有两处是指资源文件路径,请根据自己的项目结构修改(如果也可以删除相关代码SwipeControl 不需要)
  2. 如果您是将代码迁移到自己的控件库中,请记得在App.xaml
  3. 中引入SlidableListItem.xaml资源文件

<资源字典><ResourceDictionary.MergedDictionaries><ResourceDictionary Source="ms-appx:///Controls/SlidableListItem.xaml"/></ResourceDictionary.MergedDictionaries></ResourceDictionary></Application.Resources>

<小时>

但其实SwipeControl是UWP适应不同平台操作习惯的常用控件.在桌面上,我们按住鼠标左键并拖放通常用于执行传输操作,而不是调出二级菜单(我们通常在桌面上右键单击).>

在键盘和鼠标模式下模拟触摸屏操作体验有时不是一件愉快的事情.如果你打算适应多平台的操作习惯,请参考本文档添加复合命令.

Microsoft has deprecated SlidableListItem in favour of SwipeControl. I tried SwipeControl using the XAML controls gallery - it does not let me swipe left and right with a mouse (I can using SlidableListItem). I think I need a touchscreen device for it to work.

So I'd like to continue using SlidableListItem despite having updated to the latest nuget packages.

I've copied the code for SlidableListItem into my project from WindowsCommunityToolKit branch 4.0.0. I get this crash when I try to use the control:

System.TypeLoadException: Failure has occurred while loading a type.\r\n at Windows.UI.Xaml.FrameworkElement.MeasureOverride(Size availableSize)

(I successfully copied the code for the HamburgerControl into my project yesterday.)

解决方案

I tried to copy the source code of SlidableListItem, after paying attention to the following points, I successfully copied it:

  1. If you don't need SwipeControl, please delete the related code:
    • Do not copy the code of SlidableListItemSwipeControlTemplate.xaml
    • Delete the properties and callback methods related to UseSwipeControlWhenPossible in SlidableListItem.cs (such as OnUseSwipeControlWhenPossibleChanged, OnSwipeControlValueChanged, UpdateSwipeControlItems, etc.)
    • In the SledableListItem.cs file, there are two places that refer to the resource file path, please modify it according to your own project structure (you can also delete the relevant code if SwipeControl is not needed)
  2. If you are migrating the code to your own control library, please remember to introduce SlidableListItem.xaml resource file in App.xaml

<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="ms-appx:///Controls/SlidableListItem.xaml"/>
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Application.Resources>


But in fact, SwipeControl is a common control that UWP adapts to the operating habits of different platforms. On the desktop, we hold down the left mouse button and drag and drop is usually used to perform the transfer operation instead of calling out the secondary menu (we usually right-click on the desktop).

Simulating touch screen operation experience in keyboard and mouse mode is sometimes not a pleasant thing. If you plan to adapt to the operation habits of multiple platforms, please refer to this document to add compound commands.

这篇关于不能将源代码用于已弃用的控件 SlidableListItem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆