How do I create collections of sample data in Blend?
Asked Answered
A

2

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.

Adiaphorous answered 1/11, 2010 at 21:32 Comment(0)
A
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.

Adiaphorous answered 2/11, 2010 at 0:46 Comment(2)
Did you ever find a better way to do this?Lanfri
If I could give you a million points for this answer I would but I cant so have one insteadAmbala
D
0

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

Dhiren answered 1/11, 2010 at 21:41 Comment(1)
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.Adiaphorous

© 2022 - 2024 — McMap. All rights reserved.