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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:38:02+00:00 2026-06-06T18:38:02+00:00

Possible Duplicate: WPF Listview Access to SelectedItem and subitems I have a listview defined

  • 0

Possible Duplicate:
WPF Listview Access to SelectedItem and subitems

I have a listview defined as such:

<ListView Height="234.522" Name="chartListView" Width="260" SelectionChanged="chartListView_SelectionChanged" HorizontalAlignment="Left" Margin="251,38,0,38">
        <ListView.View>
            <GridView>
                <GridViewColumn Header="op1" DisplayMemberBinding="{Binding op1}" Width="50"/>
                <GridViewColumn Header="op2" DisplayMemberBinding="{Binding op2}" Width="50"/>
                <GridViewColumn Header="op3" DisplayMemberBinding="{Binding op3}" Width="50"/>
                <GridViewColumn Header="op4" DisplayMemberBinding="{Binding op4}" Width="50"/>
                <GridViewColumn Header="op5." DisplayMemberBinding="{Binding op5}" Width="50"/>
            </GridView>
        </ListView.View>
    </ListView>

I add data using the following:

chartListView.Items.Add(new { 
  op1 = "test1", op2 = "test2", op3 = "test3", op4 = "test4", op5 = "test5" });

How do I access one of the selected items so that I can see which value a column has (op3 for example)? The following code shows ALL of the values but I would only like to see op3.

MessageBox.Show(chartListView.SelectedItem.ToString());
  • 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-06T18:38:03+00:00Added an answer on June 6, 2026 at 6:38 pm

    I would suggest to use the MVVM pattern in order to connect your UI with an underlaying logic.

    On the Internet you will find plenty of information and resources regarding the M*VVM pattern*.

    The core idea is to have a ViewModel (VM) which holds data structures and variables. These data structures and variables are completely autonomous and are not depending on the UI layer in any way. The connection of the structures and variable from your VM to your UI/View (V) lies in DataBindings.

    So what you have to do (in very short terms) is to connect the ItemSource property of your list control with some underlaying data structure (the usual structure here is an ObservableCollection – read the literature to find out why).

    That’s the first step. A second step might be to add a variable of type object to your ViewModel that will hold the currently selected item of your list. To make this work you only have to connect the SelectedItem – property of your list with this variable.

    From then on whenever you select an item in your list your variable in the View is holdings its value.

    Of course this is very short termed and rather sketchy but maybe it gave you the idea to dig deeper into the MVVM pattern – it’s pretty well-thought 😉

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

Sidebar

Related Questions

Possible Duplicate: In WPF, what are the differences between the x:Name and Name attributes?
Possible Duplicate: When is Winforms the correct choice vs. WPF? Hi, I have read
Possible Duplicate: WPF versus Winforms I have been using visual C# for a while
Possible Duplicate: In WPF, what are the differences between the x:Name and Name attributes?
Possible Duplicate: WPF Image to byte[] Relative to this I have a BitmapSource image
Possible Duplicate: What WPF books would you recommend? GUI's written using WPF seem to
Possible Duplicate: Finding the Variable Name passed to a Function in C# In C#,
Possible Duplicate: WPF and cross thread operations I am having trouble with a window
Possible Duplicate: WPF Button isPressed and isEnabled problem Here is a snippet of code
Possible Duplicate: Drag WPF Popup control I created a WPF popup control in my

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.