Xamarin形式-XAML绑定的c#等价物
我想将以下XAML转换为使用C#中定义的自定义ViewCellXamarin形式-XAML绑定的c#等价物,xamarin,xamarin.forms,Xamarin,Xamarin.forms,我想将以下XAML转换为使用C#中定义的自定义ViewCell 所以转换后我有 而C# public分部类主页面:ContentPage { 公共主页() { 初始化组件(); ___listview.ItemsSource=Repository.GetList(); ___listview.ItemTemplate=新数据模板(typeof(CustomViewCell)); } } 公共类CustomViewCell:ViewCell { bool _initialized=fals
所以转换后我有
而C#
public分部类主页面:ContentPage
{
公共主页()
{
初始化组件();
___listview.ItemsSource=Repository.GetList();
___listview.ItemTemplate=新数据模板(typeof(CustomViewCell));
}
}
公共类CustomViewCell:ViewCell
{
bool _initialized=false;
公共CustomViewCell()
{
var stack=新的StackLayout();
var按钮=新按钮();
stack.Children.Add(按钮);
视图=堆栈;
}
}
在按钮的图像
和命令
属性上完成绑定语法所需的代码是什么
var button = new Button();
button.SetBinding(Button.ImageProperty, new Binding("ImageName"));
button.SetBinding(Button.CommandProperty, new Binding("ShowDetailsCommand"));