8

Let's say I have a class Person:

public class Person
{
    public string Name {get; set;}
    public int Age {get; set;}
}

I would like to create some sample data in Blend to help me design my user interface visually. I choose to create sample data based on a class in Blend, but what I get is a sample Person - singular. I want to create a collection of Person to bnd to a list box. How do I tell it to do this? I can't find anywhere where it asks. Do I have to create a class that is a collection of Person. Surely there has to be a way to do this?

Thanks in advance.

Adam Barney
  • 2,377
  • 3
  • 18
  • 24

2 Answers2

3

I found a way to do this, though not ideal.

The creation of sample data based on a class is a one-time thing. Here's what I did to get my list of Person objects in sample data:

public class Person
{
public string Name {get; set;}
public int Age {get; set;}      
}

public class PersonCollection : List<Person> {}

I created the PersonCollection class, which is simply a collection of Person objects. I then created my sample data based on the PersonCollection class - giving me the sample data I was after. I then removed the PersonCollection, leaving the sample data in place.

I'd call this a workaround rather than a solution. If anyone can offer a true solution - a way to do this in Blend without having to create summy classes, I'll be more than happy to mark that as the solution.

Adam Barney
  • 2,377
  • 3
  • 18
  • 24
0

You can use data pane->Add sample datasource->Define New Sample Data to do this.

anivas
  • 6,437
  • 6
  • 37
  • 45
  • I want it to be based on my class. I have a small Person class here to keep it simple, but in reality, I have some complex classes, with deep nested related data, and do not want to define out everything by hand. I love the ease of using the "Create Sample Data From Class...", I just want it to create a collection of my class, not just a simgular instance. – Adam Barney Nov 01 '10 at 21:51