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 7627467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:27:48+00:00 2026-05-31T05:27:48+00:00

I have encountered a major problem for myself in the learning process of WPF

  • 0

I have encountered a major problem for myself in the learning process of WPF bindings. I have to create an application that uses a Listview which look like this:

<ListView.View>
    <GridView>
        <GridViewColumn Header="ID" Width="75" DisplayMemberBinding="{Binding ID}" />
        <GridViewColumn Header="Name" Width="170" DisplayMemberBinding="{Binding Name}" />
        <GridViewColumn Header="Price" Width="100" DisplayMemberBinding="{Binding Price}" />
        <GridViewColumn Header="Reseller" Width="Auto" DisplayMemberBinding="{Binding Reseller}" />
    </GridView>
</ListView.View>

In the codebehind file I have a property:

public Product seletedRow
{
    get { return m_Product; }
    set { m_Product = value; PropertyChanged("Product"); }
}

The goal would be to set this property to the selected row of the listView and then show the fields of this property in 4 textboxes.
If I set this property manually from code I can display the information in the textboxes but I can’t figure out how to bind the object from the ListView.SelectedItem. As far as I have found I should be using OneWayToSource binding mode but I have no idea how.

I’m also opened to other solutions, as long as I can use it in MVVM pattern.

  • 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-05-31T05:27:48+00:00Added an answer on May 31, 2026 at 5:27 am

    It’s probably better to do something like this. That way you don’t even need any code-behind.

    {Binding ElementName=myListView, Path=SelectedItem.ID, UpdateSourceTrigger=PropertyChanged}
    

    You’ll need to assign ListView a name like this.

    <ListView Name="myListView">
    

    It would look something like this.

    <ListView Name="myListView">
        <ListView.View>
                    <GridView>
                        <GridViewColumn Header="ID" Width="75" DisplayMemberBinding="{Binding ID}" />
                        <GridViewColumn Header="Name" Width="170" DisplayMemberBinding="{Binding Name}" />
                        <GridViewColumn Header="Price" Width="100" DisplayMemberBinding="{Binding Price}" />
                        <GridViewColumn Header="Reseller" Width="Auto" DisplayMemberBinding="{Binding Reseller}" />
                    </GridView>
                </ListView.View>
    </ListView>
    
    <TextBox Text="{Binding ElementName=myListView, Path=SelectedItem.ID, UpdateSourceTrigger=PropertyChanged}"/>
    

    Edit:

    If you wan’t to expand on the logic you probably want to look into using ACB, as with ACB you could do something like this.

    acb:CommandBehavior.Event="SelectedItemChanged"
    acb:CommandBehavior.Command="{Binding SelectedItemChanged}"
    acb:CommandBehavior.CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}, Path=SelectedItem}"
    

    This would essentially allow you to store the specific SelectedItem each time you choose a new item on the list.

    http://marlongrech.wordpress.com/2008/12/13/attachedcommandbehavior-v2-aka-acb/

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

Sidebar

Related Questions

I have encountered a problem in my application and realized that I could fix
I have encountered the following problem which proved to me that I know far
I have encountered a problem that I have not come accross yet when setting
I have encountered a most annoying problem that occurs on the PWD variable when
I have encountered a problem. When I use jQuery to load a page that
I have encountered a problem that I want to define a map, that is
I have encountered the strange problem, that linux c++ compiler includes the files from
I have encountered a rather odd error that I do not understand. I created
I have encountered a rather nasty problem with the DataGridView control (Windows.Forms, .NET Framework
I have encountered a problem twice now whereby a producer thread produces N work

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.