wpf listbox/listview : grouped by header, but if only one item exists, only show the header?
Basically I have the following setup:
public class Sections
{
public String Heading { get; set; }
开发者_如何学编程 public String SectionTitle { get; set; }
public ICollection<MyTask> Tasks { get; set; }
}
Right now I can do the following (Group all items by header and show their tasks under them):
- Heading1
- Section1
- DoX (Clickable)
- DoY (Clickable)
- Section2
- DoFoo (Clickable)
- DoBar (Clickable)
- Section1
- Heading2
- SectionX
- DoSomething (Clickable)
- SectionY
- DoSomethingElse (Clickable)
- SectionX
- Heading3
- SpecialSection
- AccessSpecialSection (Clickable)
- SpecialSection
What I'm trying to achieve is to condense this list down:
- Heading1
- Section1
- DoX
- DoY
- Section2
- DoFoo
- DoBar
- Section1
- Heading2
- SectionX (DoSomething is hidden within this - Now SectionX is Clickable)
- SectionY (DoSomethingElse is hidden within this - Now SectionY is Clickable)
- Heading3 (SpecialSection / AccessSpecialSection is hidden within this - Now Heading3 is Clickable)
Not sure if there is an easy way to do this?
I have a feeling it will require some type of templating? where there are 4 possibilities:
- IF ONE SECTION exists in the Heading AND ONE TASK exists in the Section => Heading gets the command binding
- IF ONE SECTION exists in the Heading AND 2+ TASKS exist in the Section => Show Heading / Hide Section and the TASKS get the command binding
- IF 2+ SECTIONS exist in the Heading and ONE TASK exists in the Section => Show Heading / Show Section / Hide the TASK and give the Section the command binding
- IF 2+ SECTIONS exist in the Heading and 2+ TASKS exist in the Section => Show all and proceed as normal (TASKS get the command binding).
精彩评论