I want to create this view in Xamarin.Forms
public class HelpModel : BaseStateModel
{
ObservableCollection<HelpCellViewModel> Help { get; set; }
}
public class HelpViewModel : BaseStateViewModel<HelpModel>
{
List<HelpCellViewModel> _cellViewModels = new List<HelpCellViewModel>();
public HelpViewModel()
{
this.Title = R.String.main_tabname_help;
_cellViewModels.Add(new HelpCellViewModel()
{
});
}
}
答案 0 :(得分:1)
在xaml中,您可以按照
声明List<ListView x:Name="listView"
IsVisible="true"
ItemsSource="{x:Static local:App.BorrowedBooks}">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.View>
<StackLayout Orientation="Vertical" HorizontalOptions="CenterAndExpand">
<Label Text="{Binding Name}" HorizontalOptions="Center"/>
<Label Text="{Binding Author}" Font="10" HorizontalOptions="Center"/>
</StackLayout>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
可以在xaml.cs文件中访问它,如下所示
public BookList ()
{
InitializeComponent ();
listView.ItemSelected += (sender, e) => {
var selectedBook = (Book)e.SelectedItem;
var bookDetailsPage = new BookDetails (selectedBook);
};
}