Hello,
I have created a simple MVVM, with only three classes CashFlowView, CashFlowViewModel, CashFlowModel.
I use an infragistic's 9.1 XamDataPresenter (or xamDataGrid).
<igDP:XamDataPresenter Name="xamDataPresenter1" DataSource="{Binding Source={StaticResource CashFlowData}}">
<ObjectDataProvider x:Key="CashFlowData" ObjectType="{x:Type ViewModel:CashflowViewModel}" MethodName="GetCashFlows" />
Inside my ViewModel:
public ObservableCollection<CashflowModel> GetCashFlows()
{
return new ObservableCollection<CashflowModel>() { ... };
}
ViewModel is connected to View by this:
this.DataContext = new CashflowViewModel();
As long as I connect the grid to the ObjectDataProvider its perfectly running fine. But I wished I could just connect to a property within my ViewModel instead.
According to Infragistics all I have to do is this:
<igDP:XamDataGrid DataSource="{Binding Path=ViewModelCollection}"/>
But in this case it seems I need to bind to a collection of another ViewModel to represent my rows inside the grid. And thats where I get confused.
I tried this and it doesnt work:
<igDP:XamDataPresenter Name="xamDataPresenter1" DataSource="{Binding Path=CashFlows}">
Inside the ViewModel:
public ObservableCollection<CashflowDataGridViewModel> CashFlows
{
get
{
return new ObservableCollection<CashflowDataGridViewModel>();
}
}
But how do I create my second ViewModel (CashflowDataGridViewModel) ?
I tried adding this proprty within this second ViewModel:
public CashflowModel CashFlow
{
get
{
return new CashflowModel() {...};
}
}
But all I get shown on my view is "Cashflow" column header without any of the underlying headers of the actual cashflowModel class.
Please help, am badly stuck ;)