locked
Listview with different bindings RRS feed

  • Question

  • Hello,

    Imagine you have a listview with 2 columns.

    For the first column, you bind it with a list of companies
    For the second column you bind it with a list of users.

    The problem is that when i list companies, i cant see the users, and if i want to list users, i cant show companies.

    Or in other words, if i do listcompanies.datacontext = mycompanieslist, i cant do combobox.itemsource=mylistusers

    Can i have 2 different bindigs for different objects from the same parent?

    If its a little confusing tell me please that i explain with a real example.


    Thanks

    Monday, January 26, 2009 4:08 PM

Answers

  • A ListView can only have one DataContext.

    You have to combine the mycompanieslist and mylistusers into one collection (named mydata).
    Then you can set the DataContext of ListView as:
    listcompanies.datacontext = mycompanieslist

    For more detailed information, can you paste your demo code here?
    You can use the brush like icon on the top-right of the editor.
    Then I can compile your program and add try to add the function or feature you have asked.


    • Proposed as answer by Tao Liang Thursday, January 29, 2009 7:27 AM
    • Marked as answer by Tao Liang Thursday, January 29, 2009 7:38 AM
    Thursday, January 29, 2009 7:27 AM