【发布时间】:2019-06-12 12:09:57
【问题描述】:
我在我的项目中添加了 FlowListView。正如FAQ 中提到的那样我在点击windows 中的一项时面临整行突出显示问题,android 中没有这样的问题。我添加了如下自定义渲染器:
在主项目中:
using DLToolkit.Forms.Controls;
namespace Mynamespace
{
public class CustomFlowListView : FlowListView
{
}
}
在 UWP 中:
using Listpm;
using Listpm.UWP;
using Xamarin.Forms;
using Xamarin.Forms.Platform.UWP;
[assembly: ExportRenderer(typeof(CustomFlowListView), typeof(CustomListViewRenderer))]
namespace Listpm.UWP
{
class CustomListViewRenderer : ListViewRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<ListView> e)
{
base.OnElementChanged(e);
if (List != null)
List.SelectionMode = Windows.UI.Xaml.Controls.ListViewSelectionMode.None;
}
}
}
在 xaml 中添加了 <local:CustomFlowListView> 而不是 <flv:FlowListView>。
<local:CustomFlowListView
FlowColumnCount="2"
SeparatorVisibility="None"
HasUnevenRows="false"
RowHeight="200"
FlowItemsSource="{Binding AllItems}">
<flv:FlowListView.FlowColumnTemplate>
<DataTemplate>
<StackLayout
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand">
<Image/>
</StackLayout>
</DataTemplate>
</flv:FlowListView.FlowColumnTemplate>
</local:CustomFlowListView>
是否有任何其他更改来解决此问题?
【问题讨论】:
-
List.SelectionMode = Windows.UI.Xaml.Controls.ListViewSelectionMode.None;将禁用 ListView 行突出显示。那么你想要什么行为呢? -
-
请尝试使用此行
List.SelectionMode = Windows.UI.Xaml.Controls.ListViewSelectionMode.Single。 -
@NicoZhu-MSFT 不走运,单击一个项目时整行都会突出显示。
-
请尝试在您的渲染中添加行
List.IsItemClickEnabled = false;。
标签: xamarin.forms uwp custom-renderer