1

How can we get Number of rows Present in Listview?

2 Answers 2

3

Couldn't you just use ListView.Items.Count?

Sign up to request clarification or add additional context in comments.

3 Comments

@atul What problem are you seeing? Without more information, it's hard to provide alternative that would work for you.
Sorry Andy I Forgot to tell that i m working in MVVM Pattern, i hv to count rows of Listview in ViewModel. well in MVVM Pattern Viewmodel Doesn't know about view then hw can i use Listview.Items.Count????
What about @Kevin's suggestion to use the count of the collection bound to the control?
2

Well, you see. When you bind a list view to some sort of collection (preferably some sort of observable collection) with some sort of type. You can add/remove.

But you also have the functionality to say observablecollection.count.

Now if you are adding the items inside the XAML. a quick and easy way to access it is.

x:Name="name of the list" then in the code behind say (name of the list).count.

That should give you access within the code behind, or if you don't want to do it in the code behind. You will need some sort of window dictionary.

and you can access the (name of the list) through your dictionary.

1 Comment

By the way, if you are using the model-view-viewmodel practice. in which i use. You should bind your list view to some sort of observable collection.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.