I am looking for the right WPF control - Which one and then how?

Posted on 2012-09-13
Last Modified: 2012-09-19
Hi all.

I have a list of strings that I need to present to the user for them to choose one.  Say for example it contains the following content and is presented in a similar way.

  Basset Hound
  German Shepherd

You can see that there are 2 levels for some and potentially 2 levels for them all.  But Also I would like to be able to choose for example Dog.

I know I could just make a combobox with a collection of string and have a string of value "   Poodle" which would mean (because of the spaces in the string) it is indented, but I was hoping for a little nicer solution.

What type of WPF control should I use.  I need some kind of dropdown system as I have limited space, but I suppose a popup if that is even possible would be ok.  

What I am kinda thinking is that I need what looks like a textbox or combobox when closed.  User clicks on the right hand side and a list (mybe a treeview appears) then when a choice is made that choice is added to the textbox.
Question by:darbid73
    LVL 83

    Assisted Solution

    LVL 19

    Author Comment

    Hi CodeCruiser,

    Yes I saw this and that is why the name is in my tags.

    My first hope was something a little simpler.  Maybe a re-style of a combobox.

    Maybe a grouped Combobox where the group header could be selected and not ever entry had to be grouped.
    LVL 55

    Accepted Solution

    I would recommend not to use a tree view for a 2-level case. Treeviews are tricky and hard to implement.
    A single-level listbox or combobox with some indent for "2nd level" items would be enough.
    LVL 19

    Author Comment

    I am tending to agree with you jaime - which is what I put in my opening question about putting some space or indent into the data.

    This guy also concluded that.

    Sometimes the trick is to know the right words.  In my case the right words are "hierarchical combobox"  It appears that such data is really only suitable for a Treeview and you must "flatten it to put it into a combobox.
    LVL 19

    Author Closing Comment

    Thank you guys.

    I think both solutions are correct, but must agree that my case is simple and thus practically I should just be doing the simple solution.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
    Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now