Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 887291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:12:32+00:00 2026-05-15T13:12:32+00:00

I have created a simple MVVM, with only three classes CashFlowView, CashFlowViewModel, CashFlowModel. I

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T13:12:32+00:00Added an answer on May 15, 2026 at 1:12 pm

    To be able to bind the View to properties on the ViewModel, the DataContext needs to be set to an instance of your ViewModel. What I commonly do is to include the following line in the constructor of the code-behind for my View:

    this.DataContext = new SomeAwesomeViewModel();
    

    You can also set the DataContext for containers if you want different groups of controls to use different ViewModels (e.g., Grid.DataContext, StackPanel.DataContext, etc.).

    Once you have the DataContext set, you should be able to bind to the properties of that ViewModel.

    Update

    Here’s a bit of sample code to get you going.

    public class CashFlowViewModel
    {
        public ObservableCollection<FlowViewModel> DataGridData
        {
            get...
        }
    }
    

    That’s the property which should provide the data for the DataGrid. Now, here’s what the FlowViewModel class could look like.

    public class FlowViewModel
    {
        decimal flowAmount;
        public decimal FlowAmount
        {
            get { return flowAmount; }
            set
            {
                if(flowAmount == value)
                    return;
    
                flowAmount = value;
                NotifyPropertyChanged("FlowAmount");
            }
        }
        .
        .
        .
    
        private void NotifyPropertyChanged(string propertyName)
        {
            if(PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a very simple wpf app with mvvm light. I have rows
Could someone help me on this, I have created simple web services using axis2
How to manually create Friendly URLs? (PHP) So I have created simple php file
I have created a simple wcf service which used the WCF Service Library template.
I have created a simple grid of divs by left floating them and an
I have created a simple Asp.Net custom control which automatically combines all the correct
I have created some simple app in Java, and 'deployed' it using Java Web
I have created a simple test form with FormBorderStyle = FixedToolWindow by default and
i have created a simple public ref class in the vc++ project, which is
I have created a simple JQuery script with hovering effect on some links. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.