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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:15:23+00:00 2026-05-12T10:15:23+00:00

Enough is enough – I’ve just spent an hour searching around trying to find

  • 0

Enough is enough – I’ve just spent an hour searching around trying to find out how to read the ListViewSubItem values (if that’s correct terminology in XAML) from a ListView. Here’s a little ListView:

<ListView x:Name="CreatableAccounts" ItemsSource="{Binding Processable}" Margin="10,0">
        <ListView.View>
              <GridView>
                    <GridViewColumn Header="Site Name" DisplayMemberBinding="{Binding SiteName}"/>
                    <GridViewColumn Header="From Package" DisplayMemberBinding="{Binding FiCodeDLL.Name}"/>
                </GridView>
         </ListView.View>
</ListView>

and here’s my attempt to read the values which is clearly not going to work:

private void CreateAccounts_Click(object sender, RoutedEventArgs e)
    {
        ListViewItem selected = CreatableAccounts.SelectedItem;
        selected.Ite //  no Items, Text or similar property


    }

Can anyone point me in the right direction? Grazie in advance for your help!

  • 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-12T10:15:23+00:00Added an answer on May 12, 2026 at 10:15 am

    The ListView has a dependency property “SelectedItem” to which you can bind an instance of your collection child item, thus:

    <DockPanel>
        <Button DockPanel.Dock="Top" Click="Button_Click">Selected Item</Button>
        <ListView ItemsSource="{Binding AllItems}" SelectedItem="{Binding SelectedItem}">
            <ListView.View>
                <GridView>
                    <GridViewColumn Header="Name" DisplayMemberBinding="{Binding Name}" />
                    <GridViewColumn Header="Age" DisplayMemberBinding="{Binding Age}" />
                </GridView>
            </ListView.View>
        </ListView>
    </DockPanel>
    

    Now you can create a ViewModel that exposes an ObservableCollection filled with your items, and a single instance of an item which is your SelectedItem…

    something like:

    public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();
    
            WindowViewModel vm = new WindowViewModel();
            this.DataContext = vm;
        }
    
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            WindowViewModel vm = this.DataContext as WindowViewModel;
            MessageBox.Show(vm.SelectedItem.Name);
        }
    
    }
    
    public class WindowViewModel
    {
        public WindowViewModel()
        {
            AllItems = new ObservableCollection<Person>();
            AllItems.Add(new Person { Name = "Joe", Age = 26 });
            AllItems.Add(new Person { Name = "Mary", Age = 23 });
            AllItems.Add(new Person { Name = "Bill", Age = 32 });
            AllItems.Add(new Person { Name = "Harry", Age = 36 });
            AllItems.Add(new Person { Name = "Julie", Age = 18 });
            AllItems.Add(new Person { Name = "Claire", Age = 42 });
        }
    
        public ObservableCollection<Person> AllItems { get; set; }
    
        private Person _selectedItem;
        public Person SelectedItem
        {
            get { return _selectedItem; }
            set { _selectedItem = value; }
        }
    }
    
    public class Person : INotifyPropertyChanged
    {
    
        private string _name;
        private int _age;
    
        public string Name
        {
            get { return _name; }
            set
            {
                if (_name != value)
                {
                    _name = value;
                    RaisePropertyChanged("Name");
                }
            }
        }
    
        public int Age
        {
            get { return _age; }
            set
            {
                if (_age != value)
                {
                    _age = value;
                    RaisePropertyChanged("Age");
                }
            }
        }
    
        #region INotifyPropertyChanged Members
    
        public event PropertyChangedEventHandler PropertyChanged;
    
        private void RaisePropertyChanged(string propertyName)
        {
            if (this.PropertyChanged != null)
                this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
    
        #endregion
    }
    

    Hope this helps 🙂

    Ian

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

Sidebar

Related Questions

Is there software smart enough to figure out that you got a pointer from
Surprisingly enough I couldn't find the answer to this question. I am trying to
Sounds simple enough...but I've been plugging away at this, trying to find the one
Soon enough I will be forced to present a project in Haskell that is
Isn't having String enough? Just as an example, why can String class lets you
Simple enough question, but I cant find ant half-decent documentation on it. Right so
I know there's enough of these questions around, but I've looked through several of
After enough playing with asynchronous socket programming I noticed that the server was receiving
Anyone out there have enough experience w/ NetCDF and HDF5 to give some pluses
I know just enough about SQL tuning to get myself in trouble. Today I

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.