DelegateCommand in Listview with UserControl RRS feed

  • Question

  • How can I use DelegateCommand in my Lisview with Usercontrol? In my Listview i'm using it like that:

        <ListView x:Name="peopleListBox"> 
         <ButtonCommand="{Binding DataContext.OpenCommand, ElementName=peopleListBox}"/>                           

    I'm trying that in the UserControl:

       <Button Content="Click" Command="{Binding Path=DataContext.OpenCommand, ElementName=peopleListBox}"/>
    and this:
       <Button Content="Click" Command="{Binding Path=OpenCommand, ElementName=peopleListBox}"/>
    Neither of this codes works.

    • Edited by Yoatom_CEO Saturday, October 5, 2013 2:23 PM
    Saturday, October 5, 2013 1:51 PM

All replies

  • Sorry, not an MVVM expert.  What does "Neither of this codes works." mean?

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Monday, October 7, 2013 1:20 PM
  • Hello Yoatom!

    I didn't see where you set DataContext to your peopleListBox ListView. Can you show where you set ListView.DataContext ?

     <ListView x:Name="peopleListBox"> 

    • Edited by Oleg Kurzov Monday, October 7, 2013 1:34 PM
    Monday, October 7, 2013 1:33 PM