Bind to a collection's view and just call ToString() in WPF

Posted by womp on Stack Overflow See other posts from Stack Overflow or by womp
Published on 2010-05-27T23:39:00Z Indexed on 2010/05/27 23:51 UTC
Read the original article Hit count: 170

Filed under:
|
|
|
|

I'm binding a GridView to a collection of objects that look like this:

public class Transaction
{
   public string PersonName { get; set; }
   public DateTime TransactionDate { get; set; }
   public MoneyCollection TransactedMoney { get; set;}
}

MoneyCollection simply inherits from ObservableCollection<T>, and is a collection of MyMoney type object.

In my GridView, I just want to bind a column to the MoneyCollection's ToString() method. However, binding it directly to the TransactedMoney property makes every entry display the text "(Collection)", and the ToString() method is never called.

Note that I do not want to bind to the items in MoneyCollection, I want to bind directly to the property itself and just call ToString() on it.

I understand that it is binding to the collection's default view. So my question is - how can I make it bind to the collection in such a way that it calls the ToString() method on it?

This is my first WPF project, so I know this might be a bit noobish, but pointers would be very welcome.

© Stack Overflow or respective owner

Related posts about c#

Related posts about wpf