Greetings,
I have a Market class defined as
public class Market
{
int id,
string MarketDescription,
List<Event> Events,
....
}
and the Event is defined as
public class Event
{
int eventid,
string EventDescription
....
}
I declare
private ObservableCollection<Market> _markets;
ObservableCollection<Market> Markets
{
get { return _markets; }
set
{
_markets = value;
base.RaisePropertyChangedEvent("Markets");
}
}
In my datagrid I define my ItemSource as
ItemsSource="{Binding Markets}"
to display the data related to the Markets collection, e.g. MarketDescription (which is displayed nicely. What I want to do is to be able and display all the data related to the Event class within the same datagrid. I tried to create an ObservableCollection of Events (EventCol) and to utilise as follows
<sdk:DataGridTextColumn Header="Event Description"
x:Name="EventDescription"
Binding="{Binding ElementName=EventCol,
Path=EventDescription}"
CanUserReorder="True"
CanUserResize="True" CanUserSort="True" Width="Auto" />
Unfortunately the Events list is not displayed.
Could you please direct me to the right place or if you could possibly tell me what am I doing wrong.
Thank you
Since the events are also a collection, a simple TextColumn will not cut it. You could display a sub-datagrid by using a
DataGridTemplateColumnwhich contains aDataGridwhoseItemsSourcebinds toEvents.