English 中文(简体)
How to give a "Empty ListView Message" when there is no data source
原标题:

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?

最佳回答

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.

问题回答

暂无回答




相关问题
Will WPF be relevant with Windows 8? [closed]

With windows 8 demonstrating native HTML 5 apps . The first thing that I think of is whether WPF has a place in this HTML 5 world. It kind of seems like Silverlight will stick around but I must ask ...

Metro styled Silverlight Applications

Is there any guidance available on developing Metro styled silverlight applications? How does one go about designing the UI to match the metro look and feel of WP7. Going by the way windows 8 s UI &...

Best Alternative for Converting VB6 to run under Windows 8

I originally (many years ago) wrote my applications using VB6 on the assumption that it was a strategic Microsoft product and so I would be able to run them as long as I wanted. However with Windows 8 ...

VB6 Running on Windows 8?

Assuming that vb6 does not run on Windows 8 because the VB6 run time libraries are not shipped with Windows 8, would it not be possible to install the VB6 run time library on Windows 8 and then then ...

How to load any XAP file with the Windows Phone 7 emulator

Does anyone know if it is possible to load a windows phone 7 XAP file into the emulator without the solution or source files? In other words, can I send somebody just a XAP file so that they can test ...

热门标签