如何在xamarin形式的列表视图中显示从1到如此的行号? [英] How can a show row number from 1 to so on in a listview in xamarin forms?

查看:89
本文介绍了如何在xamarin形式的列表视图中显示从1到如此的行号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个要求,我必须创建一个listView来为每个商品添加商品编号.我有一个在项目模型中放入数字的想法,但我无法弄清楚.

I have got a requirement where I have to create a listView which adds item number with each item. I have got an idea of putting a number in model of item but I am unable to figure that out.

推荐答案

最简单的方法应该是向绑定到ListView.ItemsSourceViewModel添加一个附加属性Index屏幕.

The easiest way should be to add one additional property Index to the ViewModel that is bound to the the ListView.ItemsSource and then simply represent it on the screen.

或者,如果需要多次使用枚举的ListView,则可以创建可重复使用的控件,并将逻辑从ViewModel移到UI层.

Alternatively, if there is a need to use an enumerated ListView multiple times you could create a reusable control and move the logic from the ViewModel to the UI layer.

所以这一切都取决于您的需求.

So it all depends on your needs.

这篇关于如何在xamarin形式的列表视图中显示从1到如此的行号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆