6

My application have a ListView with GridLayout. I am now trying to introduce ListView groups into my application. Say, the data source would usually have Group1, Group2 and Group3. I would like to display all 3 groups all the time regardless there is element in it or not. When there is no element in a group, I want to display a "empty group" message under the group title.

I think the default way that WinRT handles it is not to display the empty group and it makes a lot of sense in many scenarios. To do this, I know that I maybe able to add a dummy item to the list view when there is no data, but this is kind of hacky.

So, is there a better way to do this?

1 Answer 1

-1

Just bind your ListView to a collection of Group objects (where Group is a class you define and Group1, Group2 and Group3 are such Group objects).

In addition to Group level properties (such as a Title), have a Group contain a collection of Item objects.

In the ListView's datatemplate, use another ListView to show the Item elements for each Group.

Be careful though, the nesting of GridViews will result in nested ScrollViewers. You would want to remove the ScrollViewer from the inner GridViews by changing their control template.

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

2 Comments

Thanks for the suggestions, but I don't see how this is better than adding a dummy list view item...
Well, because you don't need a dummy item? I am assuming that a dummy item will require rather complex logic to ensure the dummy item is displayed the way you want, and doesn't react to taps and clicks and other events the way a real item would. This approach removes all of that.

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.