【发布时间】: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