Konrad Viltersten
Konrad Viltersten

Reputation: 39250

Combining automatically generated columns with custom ones in the one view

I'm using automatically generated columns while binding to my view.

private ObservableCollection<Thing> _allThings;
public ListCollectionView AllThingsView { get; set; }

public Presenter()
{
  ...
  AllThingsView = new ListCollectionView(_allThings);
  ...
}

I just learned that the customer wants to show more information in the grid than the one coming from the back field. In fact, they wish to do one of two things, unclear which, so I'll have to refactor for both.

  1. Compiling additional columns based on the information already in the data.
  2. Adding columns based on a different list (same length guaranteed).

Of the top of my head, I can imagine that I'd need to introduce a new type, ThingAndOtherThing and build it so that it can automatically generate the columns. However, especially if only #1 is requested, I feel that there's another approach of simply controlling the column sin the view.

Investigating it, I realized that the event of auto-generating is called once for every column, which excludes the option of managing aditional columns from there. Where should one do that?

Upvotes: 0

Views: 66

Answers (1)

icebat
icebat

Reputation: 4774

Well, there's AutoGeneratedColumns event which is called after all columns were generated. You can add more columns manualy in its handler. It sure can be confused with AutoGeneratingColumn event which does get called for every column.
After that it all depends on where you get the data from.

Upvotes: 1

Related Questions