简体   繁体   中英

Best way to display multiple data items in WPF?

I know there has to be an easy way to do this, I just can't think of it. I need to display a set of notes in a WPF application. The layout for each note would be

Note Name Note Date Note Text

Each item above exists individually in my database access layer and I just need a way to display it. In ASP, this is something I might have created a table for and then used the repeater object to dislay it multiple times (multiple notes).

Is the ListView control the best way to go about this? How would I display multiple items next to each other as above with the NoteName and NoteDate?

You could use a ListView. In this case you would declare a GridViewColumn for each column, with the appropriate DisplayMemberBinding or CellTemplate depending on the complexity of what you wanted to show.

You could also use an ItemsControl or a ListBox, with an appropriate DataTemplate. This is good for when you do not want a strict column layout (eg you want to show the Name and Date on one line of big bold text, and the Note Text below that in smaller italic text.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM