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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:07:37+00:00 2026-05-15T19:07:37+00:00

For some reasons I cannot seem to populate a datagrid I get the following

  • 0

For some reasons I cannot seem to populate a datagrid I get the following error:

System.Windows.Data Error: 40 : BindingExpression path error: ‘Customers’ property not found on ‘object’ ”ObservableCollection`1′ (HashCode=11497055)

Can you spot what I am doing wrong?

The code is as follows:

    ViewModel
    =============
        public class CustomerVM : ViewModelBase
        {
            private ObservableCollection<Customer> _customers;          
            public ObservableCollection<Customer> Customers
            {
                get { return _customers; }
                set
                {
                    _customers = value;
                    OnPropertyChanged("Customers");
                }
            }   

            private DelegateCommand _getCustomersCommand;
            public ICommand GetCustomersCommand
            {
                get
                {
                    return _getCustomersCommand ?? (_getCustomersCommand = new DelegateCommand(x => GetCustomers(), x => CanGetCustomer));
                }
            }
            private static bool CanGetCustomer
            {
                get { return true; }
            }
            private void GetCustomers()
            {
                Customers = new ObservableCollection<Customer>
                           {
                               new Customer{Id=1,Name ="Jo",Surname = "Bloggs",IsMember = true},
                               new Customer{Id=2,Name ="Mark", Surname = "Cole",IsMember = false},
                               new Customer{Id=3,Name ="Robert ", Surname = "Smith",IsMember = true},
                               new Customer{Id=4,Name ="Vincent", Surname = "Varc",IsMember = false},
                           };
            }
        }    


          Customer Wpf Window
          ====================
          <Window x:Class="Sample.CustomerDataGridSample"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:toolkit="http://schemas.microsoft.com/wpf/2008/toolkit"
            Title="CustomerDataGridSample" Height="300" Width="300" Loaded="OnWindowsLoaded" WindowStartupLocation="CenterScreen">

        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <TextBlock Text="Customers"
                       Grid.ColumnSpan="2"
                       FontWeight="Bold"
                       FontSize="12"/>
            <toolkit:DataGrid x:Name="dg" Grid.Row="1"
                               ItemsSource="{Binding Customers}"                            
                               CanUserAddRows="False" 
                               CanUserDeleteRows="False"
                               CanUserResizeRows="False" 
                               CanUserSortColumns="False"
                               AutoGenerateColumns="False"
                               RowHeaderWidth="17" RowHeight="25">
                <toolkit:DataGrid.Columns>
                    <toolkit:DataGridTextColumn   Header="Name"
                                              Binding="{Binding Path=Name}" />
                    <toolkit:DataGridTextColumn   Header="Surname"
                                              Binding="{Binding Path=Surname}" />
                    <toolkit:DataGridTextColumn   Header="Is Member"
                                              Binding="{Binding Path=IsMember}" />
                </toolkit:DataGrid.Columns>
            </toolkit:DataGrid>
        </Grid>
    </Window>

     public partial class CustomerDataGridSample:Window
    {
        public CustomerDataGridSample()
        {
            InitializeComponent();
        }
        private void OnWindowsLoaded(object sender, RoutedEventArgs e)
        {
            var customerVm = new CustomerVM();
            customerVm.GetCustomersCommand.Execute(null);
            DataContext = customerVm.Customers;
        }
    }
  • 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-15T19:07:38+00:00Added an answer on May 15, 2026 at 7:07 pm

    The error message alone gives it away – your binding has the wrong context.

    You’re setting the DataContext of your window to customerVm.Customers in the loaded method. That means that your bindings “start” from the Customers property already, and so the binding on your grid is actually trying to find customerVm.Customers.Customers. That’s why you get the error message you do: an ObservableCollection has no Customers property.

    You can either change it so the DataContext set in code is simply customerVm, or use ItemsSource={Binding} on the DataGrid (which will then just pick up the current DataContext).

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

Sidebar

Related Questions

For some reason I cannot seem to get IE8 to display my jqgrid right
I cannot seem to get css transitions to work for some reason. I am
For some reason, no matter how I go about it, I cannot get TortoiseSVN
For some reason, I cannot get a UIWebView to play nice with my new
I'm trying to get some code going that lets me display raw trackpad data
for some reason I cannot see any of the generated objects under the TL
For some reasons, SSIS is not avalialble. I read about OPENROWSET, but I will
For some reasons, I would like to do an explicit quoting of a string
What are some reasons why PHP would force errors to show, no matter what
I was working on a project that missbehaved, for some reasons no exception was

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.