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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:34:37+00:00 2026-06-05T23:34:37+00:00

I’m finding it challenging to get data-binding working for my sample WPF application in

  • 0

I’m finding it challenging to get data-binding working for my sample WPF application in the MVVM style.

Question:

What’s missing in the following sample?


Details:

Basic Structure:

Model: Customer (doesn’t matter actually)

ViewModel: AllCustomersViewModel

View: WizardWindowView

Structural elements:

Exposed by VM: AllCustomers (of type ObservableCollection)

Displayed on View: ListView

Want Binding: ListView <-> AllCustomers


WizardWindowView.xaml:

<Window 
    ...
    ...
    <Window.Resources>
        <CollectionViewSource x:Key="CustomerGroups" Source="{Binding Path=AllCustomers}"/>
    </Window.Resources>
    
    <Grid>
            ...
            ...
            <aw:WizardPage Header="Step 1">
                <ListView
                   ItemsSource="{Binding Source={StaticResource CustomerGroups}}"/>
            </aw:WizardPage>
            ...
            ...
    </Grid>
</Window>

I’ve already spent more than 10 hours trying to understand how data-binding is accomplished and feel it’s time to ask for help!


EDIT

Model info:

Data: customers.xml

Model: Customer.cs

Data Access: CustomerRepository.cs

AllCustomersViewModel:

readonly CustomerRepository _customerRepository;
public AllCustomersViewModel(CustomerRepository customerRespository) {...}

EDIT 2

Sequence of calls:

App.xaml.cs.OnStartup() {.. new MainWindowViewModel("Data/customers.xml")..};

public MainWindowViewModel(string customerDataFile)
{
    _customerRepository = new CustomerRepository(customerDataFile);
    new AllCustomersViewModel(_customerRepository);
}

EDIT 3

DataContext:

In App.xaml.cs:

    MainWindow window = new MainWindow();
    string path = "Data/customers.xml";
    var viewModel = new MainWindowViewModel(path);
    window.DataContext = viewModel;

In MainWindow.xaml.cs (the codebehind):

private void ShowWizardWindow(object sender, RoutedEventArgs e)
{
    Views.WizardWindowView wizardWindow = new Views.WizardWindowView();
    wizardWindow.DataContext = this.DataContext;
    wizardWindow.Show();
}
  • 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-05T23:34:38+00:00Added an answer on June 5, 2026 at 11:34 pm

    After assistance from several people here, from my colleague and finally from some reading, I managed to establish data-binding! Actually, a simplified one compared to what I was originally hoping.

    Sorry, my answer might not be the most organized, but I’m sure it’ll be understandable.


    Accomplished

    Displaying names of customers.

    Here’s how

    I have a WizardWindowView (similar to a WPF Window) on which I wanted to display the names of customers. WizardPage is a window (again, similar to a WPF Window) among several windows in the wizard. I also have the data-context set as in the question’s edit section.

    Where are the names of the customers originally coming from?
    I have a data source which is an xml file. I also have a AllCustomersViewModel.cs class that gives an abstraction for the data in the xml file. If you want to know how the abstraction is done, you might have to do some reading on WPF! The abstraction is a collection of CustomerViewModel objects.

    Now, what are these CustomerViewModel objects?
    If AllCustomersViewModel abstracts the collection of customer data in the original xml file, CustomerViewModel abstracts each customer in the collection.

    What is the abstraction like or what is its type?
    CustomerViewModel exposes (this is .net jargon) a property called FirstName of type string. AllCustomersViewModel exposes a property called AllCustomers of type ObservableCollection<CustomerViewModel>.

    Now that I have the data to be displayed, I’m switching my focus to the View (xaml):
    I’m trying to display the first names of the customers on my WizardWindowView.

    Since I have to display a list and not just one or two elements in the list, I need a xaml control to display a list (ListView).

    What should the source for ListView be?

    <ListView ItemsSource="{Binding Path=AllCustomers}">
    

    To display each item in the list, I do the following:

                <ListView.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding Path=FirstName}"></TextBlock>
                    </DataTemplate>
                </ListView.ItemTemplate>
    

    Summary:

    <aw:WizardPage Header="Step 3: Edit/Check Engine (Faulty Customers)">
        <ListView ItemsSource="{Binding Path=AllCustomers}">
            <ListView.ItemTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Path=FirstName}"></TextBlock>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
    </aw:WizardPage>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I want to construct a data frame in an Rcpp function, but when I
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have some data like this: 1 2 3 4 5 9 2 6
Thanks in advance for your help. I have a need within an application to
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.