Click here to Skip to main content
15,900,461 members
Home / Discussions / WPF
   

WPF

 
QuestionBinding custom objects collection to ListBox in WPF?? Pin
mittalpa5-Nov-09 8:25
mittalpa5-Nov-09 8:25 
Hi Thanks for putting this example. But, everywhere I find example of ArrayList containg strings. Is there a way to bind a collection of custom objects?Please advise.

Something like this instead of string collection :

public AlbumCollection GetAlbums()
{
var albumCollection = new AlbumCollection();
albumCollection.Album.Add(new Album() { Description = "A1 Desc", Name = "A1 Name", Id = 1 });
albumCollection.Album.Add(new Album() { Description = "A2 Desc", Name = "A2 Name", Id = 2 });
albumCollection.Album.Add(new Album() { Description = "A3 Desc", Name = "A3 Name", Id = 3 });
albumCollection.Album.Add(new Album() { Description = "A4 Desc", Name = "A4 Name", Id = 4 });
return albumCollection;
}

--------------

public partial class AlbumCollection
{

[EditorBrowsable(EditorBrowsableState.Never)]
private List<Album> albumField;

[System.Xml.Serialization.XmlElementAttribute("Album")]
public List<Album> Album
{
get
{
if ((this.albumField == null))
{
this.albumField = new List<Album>();
}
return this.albumField;
}
set
{
this.albumField = value;
}
}
}

public partial class Album
{

[EditorBrowsable(EditorBrowsableState.Never)]
private List<Document> documentField;

public int Id { get; set; }

public string Name { get; set; }

public string Description { get; set; }


[System.Xml.Serialization.XmlElementAttribute("Document")]
public List<Document> Document
{
get
{
if ((this.documentField == null))
{
this.documentField = new List<Document>();
}
return this.documentField;
}
set
{
this.documentField = value;
}
}
}


Please advise. Thanks
Pankaj

Follow your goals, Means will follow you ---Gandhi---

AnswerRe: Binding custom objects collection to ListBox in WPF?? Pin
Mark Salsbery5-Nov-09 9:42
Mark Salsbery5-Nov-09 9:42 
QuestionNew to WPF - Would this be easy to implement? Pin
AksharRoop4-Nov-09 19:36
AksharRoop4-Nov-09 19:36 
AnswerRe: New to WPF - Would this be easy to implement? Pin
Mark Salsbery5-Nov-09 7:24
Mark Salsbery5-Nov-09 7:24 
QuestionRe: New to WPF - Would this be easy to implement? Pin
AksharRoop5-Nov-09 20:09
AksharRoop5-Nov-09 20:09 
AnswerRe: New to WPF - Would this be easy to implement? Pin
Mark Salsbery6-Nov-09 10:09
Mark Salsbery6-Nov-09 10:09 
GeneralRe: New to WPF - Would this be easy to implement? Pin
AksharRoop8-Nov-09 19:11
AksharRoop8-Nov-09 19:11 
Questionproblem with WPF graph control Pin
ranganaMIT4-Nov-09 17:18
ranganaMIT4-Nov-09 17:18 
AnswerRe: problem with WPF graph control Pin
hb521342144-Nov-09 18:04
hb521342144-Nov-09 18:04 
QuestionXAML TEmplate Pin
Saiyed Alam4-Nov-09 16:08
Saiyed Alam4-Nov-09 16:08 
AnswerRe: XAML TEmplate Pin
Richard MacCutchan4-Nov-09 23:20
mveRichard MacCutchan4-Nov-09 23:20 
QuestionHow to find a height of a Grid Row at runtime? Pin
dbrenth4-Nov-09 7:40
dbrenth4-Nov-09 7:40 
AnswerRe: How to find a height of a Grid Row at runtime? Pin
dbrenth4-Nov-09 7:49
dbrenth4-Nov-09 7:49 
GeneralRe: How to find a height of a Grid Row at runtime? Pin
d m patel4-Jan-10 22:24
d m patel4-Jan-10 22:24 
QuestionRe: How to find a height of a Grid Row at runtime? Pin
d m patel4-Jan-10 22:01
d m patel4-Jan-10 22:01 
AnswerRe: How to find a height of a Grid Row at runtime? Pin
dbrenth5-Jan-10 5:26
dbrenth5-Jan-10 5:26 
QuestionHow to animate the ListBoxItems in WPF. Pin
wasimsharp3-Nov-09 17:20
wasimsharp3-Nov-09 17:20 
Questiondrag image Pin
RongNK3-Nov-09 13:31
RongNK3-Nov-09 13:31 
AnswerRe: drag image Pin
Christian Graus3-Nov-09 13:39
protectorChristian Graus3-Nov-09 13:39 
GeneralRe: drag image Pin
RongNK3-Nov-09 15:25
RongNK3-Nov-09 15:25 
GeneralRe: drag image Pin
Christian Graus3-Nov-09 16:29
protectorChristian Graus3-Nov-09 16:29 
GeneralRe: drag image Pin
RongNK3-Nov-09 20:19
RongNK3-Nov-09 20:19 
GeneralRe: drag image Pin
Mark Salsbery4-Nov-09 8:02
Mark Salsbery4-Nov-09 8:02 
GeneralRe: drag image Pin
Christian Graus4-Nov-09 11:37
protectorChristian Graus4-Nov-09 11:37 
GeneralRe: drag image Pin
Mark Salsbery4-Nov-09 11:50
Mark Salsbery4-Nov-09 11:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.