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 6341087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:57:43+00:00 2026-05-24T19:57:43+00:00

I asked about how does it work with INotifyPropertyChanged interface( How does WPF INotifyPropertyChanged

  • 0

I asked about how does it work with INotifyPropertyChanged interface( How does WPF INotifyPropertyChanged work? ), and it requires me to connect XAML’s DataContext to the INotifyPropertyChanged inherit instances as follows.

MainViewModel model = new MainViewModel();        
this.DataContext = model;

And I also found a recommendation to have a comment for DataContext that each XMAL uses( http://joshsmithonwpf.wordpress.com/2009/10/24/xaml-tip-datacontext-comment/ ).

When I have multiple XAML files, and when I want to link the DataContext to different ViewModel, I guess I need to make the each XAML.CS file to contain this code (model varies for each xaml.cs) :this.DataContext = model;.

  • Is this correct?
  • How can I do the same thing in XAML file?
  • What’s the magic behind this DataContext thing? I mean, how does DataContext work?
  • 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-24T19:57:44+00:00Added an answer on May 24, 2026 at 7:57 pm
    • Yes that is correct as far as i know, since this is quite repetetive some MVVM frameworks do this linking for you.

    • In XAML:

      <UserControl ...
                   xmlns:vm="clr-namespace:MyApp.ViewModels">
          <UserControl.DataContext>
              <vm:MyViewModel />
          </UserControl.DataContext>
          <!-- ... -->
      </UserControl>
      
    • It enables short bindings where the Path is relative to the DataContext, e.g. {Binding Name} binds to DataContext.Name. It also is inherited which can be useful.

    Please read the Data Binding Overview if you haven’t.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I asked about getting iTextSharp to render a PDF from HTML and a CSS
I asked about Choosing a method to store user profiles the other day and
I asked about finding in subdirs with criteria. First answer was use FindFirstFileEx(). It
I recently asked about keyword expansion in Git and I'm willing to accept the
I keep getting asked about AppDomains in interviews, and I know the basics :
Last time I asked about the reverse process , and got some very efficient
Okay I know I asked about this before, and the answer was basically cache
I saw this question asked about C# I would like an answer for PHP.
Another poster asked about preferred syntax for infinite loops . A follow-up question: Why
Another question asked about determining odd/evenness in C, and the idiomatic (x & 1)

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.