Listview custom usercontrol interaction RRS feed

  • Question

  • Question ...

    How can I databind an observablecollection to a listview, and still be able to interact with the custom usercontrol that's being displayed in the listview?

    example, the facebook app I imagine is using a listview control to display each item on my wall/feed. I can click the like button on the usercontrol that is being displayed in the feed and the whole facebook post is not clicked.   When I try to duplicate that, I cant click on the "like" button ... in my case its not a like button but the example fits. when I try to click the like button, the entire post is clicked which is not good.

    another example, if I add a custom usercontrol to my project, that has 2 buttons on it, each with their own tap event, and then bind an observablecollection<customUserControl> that to the listview, the entire object/usercontrol is interactable when I tap it (similar to the email client on windows phone), not the individual buttons on the control. This is not my desired interaction. I need to be able to interact with the

    I hope that makes sense and I hope you can point me in the right direction.


    Saturday, August 30, 2014 10:28 PM


  • If you are not wanting the selection behavior that comes with a listview, you can use an ItemsControl instead. You can bind an Observable Collection to this the same way as a ListView, but the items do not get selected when you click on them.

    If all of your functionality is being done by the custom control you are using (or more specifically the sub-components of it), and you do not need to actually select the item itself, this should work fine.

                <uc:MyCustomControl CustomDependencyProperty="{Binding PropertyName"} />

    • Proposed as answer by DaveH120 Sunday, August 31, 2014 10:02 PM
    • Marked as answer by Jamles HezModerator Tuesday, September 9, 2014 7:13 AM
    Sunday, August 31, 2014 10:01 PM