Syncfusion SfListView 不选择项目

Syncfusion SfListView not selecting items

所以我有这个列表,我需要从中 select 项,但我无法使 selection 功能正常工作,这是我的代码:

        <syncfusion2:SfListView SelectionMode="Multiple"
            SelectionGesture="Tap"
            x:Name="bandSch"
            SelectionBackgroundColor="#e8e8e8"
            AbsoluteLayout.LayoutBounds="0,0.8,1,0.3"
            AbsoluteLayout.LayoutFlags="All"
            ItemSize="40"
            ItemsSource="{Binding Source={local2:BandInfoRepository}, Path=BandInfo}">
            <syncfusion2:SfListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell>
                        <StackLayout Padding="5,0,5,5" Orientation="Horizontal">
                            <Label Text="{Binding BandSchedule}"
                                TextColor="#00b5d1"
                                FontSize="12" 
                                FontAttributes="Bold"
                                HorizontalOptions="FillAndExpand"
                                HorizontalTextAlignment="Center"
                                VerticalOptions="FillAndExpand"
                                VerticalTextAlignment="Center"
                                WidthRequest="50"
                            />
                            <Button Text="Seleccionar"
                                FontSize="16"
                                TextColor="#00b5d1"
                                BackgroundColor="#e8e8e8"
                                Margin="5"
                                HorizontalOptions="FillAndExpand"
                                VerticalOptions="FillAndExpand"
                                BorderRadius="14"

                            />
                        </StackLayout>
                    </ViewCell>
                </DataTemplate>
            </syncfusion2:SfListView.ItemTemplate>
        </syncfusion2:SfListView>

我希望得到一点帮助,因为我无法让单个或多个 selection 工作,我也不知道为什么。

由于 SfListViewRenderer 可能未初始化或渲染程序集可能未添加为渲染器项目中的引用,因此报告的问题“SfListView 中未引发选择事件”。因此,我们建议参考以下UG文档link来初始化每个渲染器项目所需的SfListView渲染器和程序集,以解决示例级别的问题。

在每个平台上启动 SfListView: https://help.syncfusion.com/xamarin/sflistview/getting-started#launching-the-sflistview-on-each-platform

每个平台所需的程序集: https://help.syncfusion.com/xamarin/sflistview/getting-started#sflistview-for-xamarinforms

如果您需要进一步的帮助,请告诉我们。

此致,
迪内什·巴布·亚达夫

在我自己努力解决这个问题之后,我发现这可能是多种问题的结合导致的。在我的场景中,我在 iOS AppDelegate.cs 文件中初始化了代码,但我在数据模板中为项目设置了背景颜色。看起来,如果您在项目上设置背景颜色,则选择操作不会更改背景。这导致它看起来好像选择操作不正确,而实际上它只是背景颜色在选择时没有改变。在我的例子中,我删除了项目背景并让选择背景在选择时改变背景颜色。这解决了我的问题。

关于 AppDelegate.cs 中渲染器的初始化,我想提一下 Visual Studio 2017 Community Edition 中的自动完成功能并没有帮助我找到我需要的导入路径允许我调用渲染器的初始化函数。经过大约 30 分钟的挫折,我在下面的包裹中找到了它。希望这能在将来为其他人节省一些时间。

在顶部使用语句:

using Syncfusion.ListView.XForms.iOS;

我的 FinishedLaunching 是什么样子的。

public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            global::Xamarin.Forms.Forms.Init();
            // Call the INIT.
            SfListViewRenderer.Init();
            mainForms = new App();  
            LoadApplication(mainForms);

            return base.FinishedLaunching(app, options);
        }