Choosing right control for list of items
Posted
by
prostynick
on Stack Overflow
See other posts from Stack Overflow
or by prostynick
Published on 2011-01-31T20:28:58Z
Indexed on
2012/04/12
23:29 UTC
Read the original article
Hit count: 180
I am new to WPF and MVVM. In my ViewModel
I have collection of items, for example:
class Item {
string Title {get; set;}
string Description {get; set;}
}
I would like to create a view, so at the beginning I would have:
Title1
Title2
Title3
If user click on one of title it will expand to show description, eg:
Title1
Description1
Title2
Title3
If user click on other title, there will be two expanded items:
Title1
Description1
Title2
Description2
Title3
This is probably very similar to Expander
control and maybe I could use it, but I am doing it other way, to learn something new.
What control should I use for this purpose? Should that be ItemsControl
or maybe ListBox
?
I imagine, that if I use ItemsControl
, I should probably extend my Item
class to have something like bool IsExpanded
and bind UI item visibility to that value. But maybe I could use ListBox
and somehow bind UI item visibility to... Yeah, to what? :)
How could I do such a simple thing?
© Stack Overflow or respective owner