none
ListView WPF

    Question

  • Hello!

    I have question. Is it possible to bind data to rows in the ListView -object? For instance: 1st row presents only pictures, second row presents only names and the third - ages.

    I'm trying to figure it out, how it can be done. But I got stuck in.

    Thank you beforehand for answers.

    Monday, March 26, 2012 2:20 PM

Answers

All replies

  • Do you know how many items there are in each row?
    Monday, March 26, 2012 2:25 PM
  • Hi,

    have yuo tried using a datatemplate selector? Then depending on the type in the object (row) you use some custom logic to work this bit out. and you bind the row to a datatemplate that dispalys images or ages etc

    Heres a link to get you started -

    http://www.switchonthecode.com/tutorials/wpf-tutorial-how-to-use-a-datatemplateselector

    • Marked as answer by DmitrijN Monday, March 26, 2012 3:11 PM
    Monday, March 26, 2012 2:50 PM
  • Do you know how many items there are in each row?
    Yes, I know. So, basically it's predefined number. Each row contains only three items.
    • Edited by DmitrijN Monday, March 26, 2012 3:00 PM
    Monday, March 26, 2012 2:55 PM
  • Hi,

    have yuo tried using a datatemplate selector? Then depending on the type in the object (row) you use some custom logic to work this bit out. and you bind the row to a datatemplate that dispalys images or ages etc

    Heres a link to get you started -

    http://www.switchonthecode.com/tutorials/wpf-tutorial-how-to-use-a-datatemplateselector

    No, I didn't. It doesn't seem to be hard. But I guess, it will be.

    Thank you for the link. 

    • Edited by DmitrijN Monday, March 26, 2012 3:00 PM
    • Marked as answer by DmitrijN Monday, March 26, 2012 3:11 PM
    • Unmarked as answer by DmitrijN Monday, March 26, 2012 3:11 PM
    Monday, March 26, 2012 2:57 PM
  • The you should use the datatemplateselector pritesh3  suggested.

    You can bind your listview to an observablecollection<object> and insert ex. 4 images, then 4 names, and then 4 integers.

    Then the datatemplateselector will do the rest!

    • Marked as answer by DmitrijN Monday, March 26, 2012 3:11 PM
    Monday, March 26, 2012 2:59 PM
  • The you should use the datatemplateselector pritesh3  suggested.

    You can bind your listview to an observablecollection<object> and insert ex. 4 images, then 4 names, and then 4 integers.

    Then the datatemplateselector will do the rest!

    Thank you very much. I forgot about that at all. I tried to use a common collection and astonished, how it can be implemented=)
    Monday, March 26, 2012 3:11 PM