我目前正在使用 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" }
};
谢谢。