I've the following classes:
class Event {
int eserc {get;set;}
int type {get;set;}
}
class Sequence {
List<Event> events;
int freq {get;set;}
}
As you can see, I have a list of events inside a Sequence. I have a list of Sequence.
I want to show a ListView with a GridView with the list of sequences. For each sequence I want to have 2 columns, one with the value of the property freq and the other one should have the list of events associated with that sequence. For example:
where the first line is related to the first sequence. The color of the rectangle represents the event's type. In the first sequence there are the following events:
- eserc 1 of type "red"
- eserc 2 of type "red"
- eserc 3 of type "green"
- eserc 4 of type "red"
I know that I have to do the binding to display values, but I don't know how to do it for the sequences, because I should bind the value of the column to the values of the Event objects within each single Sequence.
That's the code that I wrote for the ListView:
<ListView Name="resultsList" Grid.Row="5" Grid.Column="1"
Grid.ColumnSpan="3">
<ListView.View>
<GridView>
<GridViewColumn Header="Sequence" Width="450"
DisplayMemberBinding="{Binding events}"/>
<GridViewColumn Header="Frequence"
DisplayMemberBinding="{Binding freq}"/>
</GridView>
</ListView.View>
</ListView>
Of course, Binding events is wrong because that would work only if it was a string, but that's the idea.
I searched on internet and I think that I should use something like DataTemplate, but I'm not sure about that and I didn't understand well how that works. I understood that it works when the source is an object, but in this case it's a List of objects and I don't know how to get the information.