Answer the question
In order to leave comments, you need to log in
How to override .ToString() for a collection in DataGrid WPF?
Hello. WPF. Faced such a problem. I want the datagrid to display the contents of the collection separated by commas instead of "(Collection)".
I tried to make my own class inherited from a regular sheet and overridden .ToList() in it. Then I passed this collection to the datagrid and still - "(Collection)"
public class OrderStringCollection<Orderstring> : List<Orderstring>
{
public override string ToString()
{
return string.Join(", ", this);
}
}
Answer the question
In order to leave comments, you need to log in
In xaml, use the converter for the field. Like {Binding Orders, Converter={staticres converter}} and in the converter just go through the data you need and create the desired string
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question