Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9285469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T19:10:27+00:00 2026-06-18T19:10:27+00:00

I have a WPF model which contains a viewsource, a listview, and a button,

  • 0

I have a WPF model which contains a viewsource, a listview, and a button, which is meant to execute an ICommand in the viewmodel for the item selected in the listview.

<Window.Resources>
    <CollectionViewSource x:Key="teachingSessionsViewSource" d:DesignSource="{d:DesignInstance {x:Type local:TeachingSessionListItem}, CreateList=True}"/>
</Window.Resources>
...
    <GroupBox Header="All Sessions" 
              DataContext="{Binding Source={StaticResource teachingSessionsViewSource}}">
        <StackPanel>
            <ListView x:Name="TeachingSessionList" 
                      ItemsSource="{Binding}"
                      SelectedItem="{Binding Path=/}">
                <ListView.View>
                    <GridView ColumnHeaderContainerStyle="{StaticResource noHeaderStyle}">
                        <GridViewColumn DisplayMemberBinding="{Binding SessionDate}"/>
                        <GridViewColumn DisplayMemberBinding="{Binding PresenterInitials}" Width="30" />
                    </GridView>
                </ListView.View>
            </ListView>
            <Button Content="Un-Assign" Margin="5,5" Command="{Binding Path=/UnAssignPresentation}" 
        </StackPanel>
    </GroupBox>

The problem is that the ICommand UnAssignPresentation is always executed on the first item in the list, regardless of which item is selected in the listview. That is to say, the currentItem property of the CollectionViewSource does not seem to be bound to the ListView.

What am I doing wrong? Thank you very much.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T19:10:29+00:00Added an answer on June 18, 2026 at 7:10 pm

    Try adding IsSynchronizedWithCurrentItem="True" to your ListView.

    Also, prefer binding listview to a collection in your view model and not to a resource.
    You can then add a property to the view model for the selected item
    and bind the listview’s selected item to that property in the view model
    and either bind the button’s command to a command in the view model that acts on the current item,
    or pass the item you want to act on via the command parameter binded to the selected item.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using WPF with model-view-viewmodel pattern. I have a ResultsView and ResultsViewModel which
I have a WPF TreeView which displays my ViewModel. I have a button that
I am working in wpf - mvvm model. I have a textbox which holds-
My Model implements INotifyPropertyChanged , and I have a WPF window bound to it
I have a WPF application. I am using MVVM. I have Person Model which
I have a wpf window which is used to add as well as edit
I have a WPF application with a Linq to SQL model. In the .dbml
I have run into a problem w/ my model for databinding in WPF. I
I have WPF Form which has many buttons with the same code. Appearance of
I have a WPF application which connects to a remote database over internet and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.