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

  • Home
  • SEARCH
  • 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 6634031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:52:57+00:00 2026-05-25T22:52:57+00:00

Ok, so I am trying to implement a fairly straightforward feature in my app.

  • 0

Ok, so I am trying to implement a fairly straightforward feature in my app. I want to have a list of processes running (listed by their process name, ID, whatever) and when I click on a process in the list, update a few labels with information on that process (again, process name, ID, stuff like that).

After having a look at MSDN docs for DataBinding with Collections, I created my own custom class ProcessList that inherits from ObservableCollection. The class is completely bare now, I had previously been messing around with it trying to get things to work so I guess I may as well just be working straight with an ObservableCollection, but anyway. Here is what I have at the moment:

    public partial class MainWindow : Window
    {
        private Dictionary<int, Injector> injectors;
        public Process[] processes;
        public ProcessList procList;

        public MainWindow()
        {
            procList = new ProcessList();
            foreach (var p in Process.GetProcesses())
            {
                procList.Add(p);
            }
            InitializeComponent();
            processGrid.DataContext = procList;
        }

        private void button_refresh_processes_Click(object sender, RoutedEventArgs e)
        {
            processes = Process.GetProcesses();
        }
    }
}

And the pertinent XAML:

<Grid Name="processGrid" Margin="0,21,0,0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="348*" />
                        <ColumnDefinition Width="145*" />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="147*" />
                        <RowDefinition Height="42*" />
                    </Grid.RowDefinitions>
                    <Button Content="Inject" Grid.Row="1" Height="23" HorizontalAlignment="Center" Margin="0,0,0,0" Name="button_inject" VerticalAlignment="Center" Width="75" />
                    <ListBox Height="147" HorizontalAlignment="Left" Name="process_list" VerticalAlignment="Top" Width="348" ItemsSource="{Binding Path=ProcessName}" />
                    <Grid Grid.Column="1" Height="147" HorizontalAlignment="Left" Name="grid2" VerticalAlignment="Top" Width="145">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="1*" />
                            <RowDefinition Height="1*" />
                            <RowDefinition Height="1*" />
                            <RowDefinition Height="1*" />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="1*" />
                            <ColumnDefinition Width="1*" />
                        </Grid.ColumnDefinitions>
                        <Label Content="Process ID:" Grid.RowSpan="1" Height="28" HorizontalAlignment="Left" Margin="0" Name="label_pid" VerticalAlignment="Center" />
                        <Label Content="PID" Grid.Column="1" Grid.RowSpan="1" Height="28" HorizontalAlignment="Right" Margin="0" Name="label_pid_value" VerticalAlignment="Center" />
                    </Grid>
                    <Button Content="Refresh" Grid.Row="1" Height="23" HorizontalAlignment="Left" Margin="6,9,0,0" Name="button_refresh_processes" VerticalAlignment="Top" Width="75" Click="button_refresh_processes_Click" />
                </Grid>

The problem I am currently having is that instead of displaying a list of all currently running processes by their ProcessName, it instead lists what appears to be each character from the first process’s name as seperate entries in the list, and nothing more. Screenshot

I have no idea what is going on, though I’m sure I’m doing something extremely stupid as I am very new to WPF development and Data Binding.

  • 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-25T22:52:57+00:00Added an answer on May 25, 2026 at 10:52 pm

    I am wondering why you are getting an output at all.

    ItemsSource="{Binding Path=ProcessName}"
    

    Means the source of items is the ProcessName. The name is a string and a string is an IEnumerable<Char>. So the listbox displays each char as one entry.

    You have to set the ItemsSource to the list itself. In your case it would be

    ItemsSource="{Binding}"
    

    Because the ProcessList is already the data context of your grid, which gets inherited to the listbox.

    If you are not using a view model class (which is best practice when working with the MVVM pattern) you can do a DataContext = this; in your windows constructor to set the data context of the window to its own code-behind. If you do this the binding of your list would change to

    ItemsSource="{Binding procList}"
    

    However you should introduce a property and implement INotifyPropertyChanged so your UI is notified and updated when the datasource changes.

    TL;DR version: taking a look at guides to XAML/Bindings and the MVVM Pattern is required if you want to take use full use of WPF.

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

Sidebar

Related Questions

I'm trying to implement what I think is a fairly simple design. I have
I'm fairly new to iPhone programming and am trying to implement a double-component PickerView.
Trying to implement a UITableView of names similar to the built-in Contacts iPhone app
im trying to implement a custom error page, what i want to be able
I'm fairly new to Lua, I've been working on trying to implement Lua scripting
I am a beginner interested in Haskell, and I have been trying to implement
I am trying to create a simple 3-D app for android that will have
I have a straightforward NSDocument -based Mac OS X app in which I am
I'm trying to implement a fairly simple card game in Python so that two
I'm fairly new to Rails and I'm trying to implement a really basic user

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.