locked
Extending ItemsControl RRS feed

  • Question

  • I've been looking around and haven't found a good example of someone extending ItemsControl. Is there one anywhere?
    Tuesday, December 2, 2008 3:24 PM

Answers

  • They are not difficult, but in lot of cases you can just use ItemsControl and set the ItemsPanel and ItemsTemplate to get what you want. It is so flexible to use you seldom need to build a custom control based on it.

    If you want a sample, here is a accordion control code you can take a look:

    http://silverlight.net/forums/p/19471/104937.aspx#104937

    Tuesday, December 2, 2008 8:52 PM

All replies

  • Actually I guess I really want to extend Selector, but an example of either would be useful.
    Tuesday, December 2, 2008 3:58 PM
  • What do you mean by "extending" ItemsControl? ListBox and ComboBox are all inherited from ItemsControl if that's what you mean by "extending". You could take a look at the code using Reflector.

    Tuesday, December 2, 2008 6:01 PM
  • Yes, that's what I mean by extending, but I was hoping for a simpler example than the shipped controls. It seems like no one writes ItemsControls because they're too difficult or something.
    Tuesday, December 2, 2008 6:13 PM
  • They are not difficult, but in lot of cases you can just use ItemsControl and set the ItemsPanel and ItemsTemplate to get what you want. It is so flexible to use you seldom need to build a custom control based on it.

    If you want a sample, here is a accordion control code you can take a look:

    http://silverlight.net/forums/p/19471/104937.aspx#104937

    Tuesday, December 2, 2008 8:52 PM
  • The problem I'm having with just using ItemsControl/ItemsPanel/ItemsTemplate is that there is no functionality for specifying a selected item (and in my case, multiple items). It also seems like I can't trap MouseLeftButtonUp on my items, as ItemsControl seems to swallow them.
    Tuesday, December 2, 2008 10:21 PM
  • It's too late for me right now, but I found an article on extending ItemsControl within my own delicious links. Guess I should have looked there first. http://www.silverlightshow.net/items/How-to-inherit-from-ItemsControl-and-create-a-UniformGrid-with-containers.aspx
    Tuesday, December 9, 2008 11:12 AM
  • Lately I’ve done a lot of work around customizing & inheriting from ItemsControl and I collected all the data on the subject at:

    http://www.ladimolnar.com/Home/ViewArticle.aspx?ArticleName=HowToCustomizeAnItemsControl. Also a sample app at http://www.ladimolnar.com/Projects/ItemsControlDemo.

    Monday, October 4, 2010 7:02 AM