【发布时间】:2016-06-01 07:46:25
【问题描述】:
我目前正在使用 XLabs 的 CustomRadioButton 组件。我从示例中了解到,您可以通过为 BindableRadioGroup 的 ItemsSource 属性提供一个字符串数组来设置单选按钮的文本。
示例:
BindableRadioGroup buttonGroup = new BindableRadioGroup();
ansPicker.ItemsSource = new[]
{
"Red",
"Blue",
"Green",
"Yellow",
"Orange"
};
现在,我想现在是否可以对一个对象做同样的事情。
示例:
public class Person {
private string name;
private int age;
}
如果我有这个 Person 对象的列表,我可以将它直接提供给 BindableRadioGroup 的 ItemsSource 属性吗?如何定义将在 CustomRadioButton 上显示的属性?
我为 ListView 找到了此方法,但在我的情况下,我找不到 BindableRadioGroup 的 ItemTemplate 属性:
var template = new DataTemplate (typeof (TextCell));
// We can set data bindings to our supplied objects.
template.SetBinding (TextCell.TextProperty, "FullName");
template.SetBinding (TextCell.DetailProperty, "Address");
itemsView.ItemTemplate = template;
itemsView.ItemsSource = new[] {
new Person { FullName = "James Smith", Address = "404 Nowhere Street" },
new Person { FullName = "John Doe", Address = "404 Nowhere Ave" }
};
谢谢。
【问题讨论】:
标签: xamarin radio-button xamarin.forms itemssource xamarin.forms.labs