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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:42:01+00:00 2026-05-22T02:42:01+00:00

How do I get VS to populate my ListView with sample data in the

  • 0

How do I get VS to populate my ListView with sample data in the Design panel?

I’m stumped. I’ve done a fair bit of reading and googling and can’t find a solid answer. Showing fake data in the VS Design panel would greatly speed up theming as I wouldn’t have to debug it every few changes.

Here is my code:

XAML:

<ListView DataContext="{Binding}"
          Name="PeopleListView">
    <ListView.ItemTemplate>
        <DataTemplate DataType="Person">
                <WrapPanel>
                    <TextBlock Text="{Binding Path=FirstNameView}"/>
                    <TextBlock Text="{Binding Path=LastNameView}" />
                </WrapPanel>
        </DataTemplate>
    </ListView.ItemTemplate>
</ListView>

COLLECTION:

public class People : ObservableCollection<Person>
{
    public People()
    {
        this.Add(new Person() { FirstName = "John", LastName = "Doe" });
        this.Add(new Person() { FirstName = "John", LastName = "Doe" });
        this.Add(new Person() { FirstName = "John", LastName = "Doe" });
    }
}

MAIN:

private People PList;

public MainWindow()
{
    this.PList = new People();
    PeopleListView.ItemsSource = this.PList;
}

EDIT & PROGRESS:

I read through the tutorials found in the link provided by Matt West. They were very helpful. I almost got this figured out.

I ran into a problem when the Designer tries to display the Sample Data. I get this error on my sample properties: Writable property or collection expected. I understand the error, I just don’t know how to fix it without giving each property a set statement.

Here is my code:

Person Class:

public class Person : INotifyPropertyChanged
{
    private string _FirstName;
    private string _LastName;

    public string FirstName
    {
        get { return this._email; }
        set
        {
            this._FirstName = value;
            OnPropertyChanged("FirstName");
            OnPropertyChanged("FirstNameView");
        }
    }
    public string LastName
    {
        get { return this._password; }
        set
        {
            this._LastName = value;
            OnPropertyChanged("LastName");
            OnPropertyChanged("FirstNameView");
        }
    }
    public string FirstNameView
    {
        get { return this.FirstName; }
    }
    public string LastNameView
    {
        get { return this.LastName; }
    }

    public event PropertyChangedEventHandler PropertyChanged;
    private void OnPropertyChanged(string propertyName) { /*...*/ }
}

PeopleViewSampleData.xaml:

<sample:People xmlns:sample="clr-namespace:MyProgram">
    <sample:Person FirstNameView="John" LastNameView="Doe" />
</sample:People>  

EDIT, SOLUTION:
Having ItemSource, DataContext, and :DataContext setup as follows made it work. If any of that was missing, nothing would show.

<ListView ItemsSource="{Binding}"
          DataContext="{Binding}"
          d:DataContext="{d:DesignData Source=/SampleData/PeopleListViewSampleData.xaml}"/>
  • 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-22T02:42:02+00:00Added an answer on May 22, 2026 at 2:42 am

    I don’t think you need to set DataContext on the people list view AND set the ItemsSource. Get rid of the DataContext={Binding}. Not sure if this will solve your Design problem or not. In general its usually a good idea to use the d:DesignData and d:DesignInstance properties for this though. Here is a tutorial:
    http://karlshifflett.wordpress.com/2009/10/28/ddesigninstance-ddesigndata-in-visual-studio-2010-beta2/

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

Sidebar

Related Questions

We get a large amount of data from our clients in pdf files in
I get this error: Can't locate Foo.pm in @INC Is there an easier way
I get this error on an update panel within a popupControlExtender which is within
I'm trying to get images to display in a WPF ListView styled like a
I'm trying to write a custom method to populate a ListView control using Generics:
http://jqueryui.com/demos/accordion/#event-changestart I'm trying to have an JQuery ajax request get some data and populate
We get the following error; The request was aborted: Could not create SSL/TLS secure
I get an Access is Denied error message when I use the strong name
I get a URL from a user. I need to know: a) is the
I get the following error when running my Visual Studio 2008 ASP.NET project (start

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.