【问题标题】:Xamarin.Forms.Labs - Checkboxes in ListView not working on Windows Phone 8?Xamarin.Forms.Labs - ListView 中的复选框在 Windows Phone 8 上不起作用?
【发布时间】:2014-10-27 20:40:50
【问题描述】:

我想在 Xamarin.Forms 应用程序中显示复选框列表(使用 Xamarin.Forms.Labs 库中的控件)。我按照Xamarin.Forms.Labs wiki 正确初始化了应用程序。

它在 Android 上运行良好,但是当我在 Windows Phone 8 模拟器上尝试它时,复选框在单击/点击时不会改变它们的状态。

我有以下 XAML:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
                       xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                       xmlns:controls="clr-namespace:Xamarin.Forms.Labs.Controls;assembly=Xamarin.Forms.Labs"
                       x:Class="App4.CheckBoxPage">
  <StackLayout>
    <ListView x:Name="listView">
      <ListView.ItemTemplate>
        <DataTemplate>
          <ViewCell>
            <ViewCell.View>
              <controls:CheckBox DefaultText="{Binding}" HorizontalOptions="FillAndExpand" TextColor="White" FontSize="25" />
            </ViewCell.View>
          </ViewCell>
        </DataTemplate>
      </ListView.ItemTemplate>
    </ListView>
  </StackLayout>
</ContentPage>

...以及后面的简单代码:

using System;
using System.Linq;

using Xamarin.Forms;

namespace App4
{    
    public partial class CheckBoxPage : ContentPage
    {    
        public CheckBoxPage ()
        {
            InitializeComponent ();
            listView.ItemsSource = Enum.GetValues(typeof(DayOfWeek)).OfType<DayOfWeek>().Select(c => c.ToString());
        }
    }

    public class App
    {
        public static Page GetMainPage()
        {
            return new CheckBoxPage();            
        }
    }
}

任何想法如何让复选框工作?

【问题讨论】:

  • 您正在初始化 Xamarin Forms Labs 吗?你有其他可用的渲染器吗?

标签: c# xaml windows-phone-8 xamarin xamarin.forms


【解决方案1】:

似乎,因为它现在根本不适用于 iOS 和 WP。 在 Android 上,您必须设置 TextColor(否则不显示文本)。 但是... XLabs 团队知道这些问题。

参见此处:XF-forum-thread

这里:Issues-Page on XLabs

希望这会有所帮助...

【讨论】:

    猜你喜欢
    • 2014-05-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-20
    • 1970-01-01
    相关资源
    最近更新 更多