开发者

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
      1. DoX (Clickable)
      2. DoY (Clickable)
    • Section2
      1. DoFoo (Clickable)
      2. DoBar (Clickable)
  • Heading2
    • SectionX
      1. DoSomething (Clickable)
    • SectionY
      1. DoSomethingElse (Clickable)
  • Heading3
    • SpecialSection
      1. AccessSpecialSection (Clickable)

What I'm trying to achieve is to condense this list down:

  • Heading1
    • Section1
      1. DoX
      2. DoY
    • Section2
      1. DoFoo
      2. DoBar
  • 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).
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜