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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T20:03:25+00:00 2026-05-14T20:03:25+00:00

I speak about josh smith article. can anyone show me please how the CustomerView.xaml

  • 0

I speak about josh smith article.

can anyone show me please how the CustomerView.xaml specifically this:j

 <TextBox 
  x:Name="firstNameTxt"
  Grid.Row="2" Grid.Column="2" 
  Text="{Binding Path=FirstName, ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged}" 
  Validation.ErrorTemplate="{x:Null}"
  />

Why is there a Binding to FirstName which is public property in the CustomerViewModel.

There is a datacontext set for the MainViewModel, but not for the CustomerViewModel, so why does the binding 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-14T20:03:26+00:00Added an answer on May 14, 2026 at 8:03 pm

    Check out the ResourceDictionary in MainWindowResources.xaml. Josh uses the following code to describe what View should be used if an instance of CustomerViewModel is shown in the main window:

       <DataTemplate DataType="{x:Type vm:CustomerViewModel}">
            <vw:CustomerView />
       </DataTemplate>
    

    We’ve described that when our DataType is of Type CustomerViewModel, we’ll create a new instance of the CustomerView. WPF takes care of the DataContext and creation when it sees the CustomerViewModel type.

    From the rest of the article:

    Applying a View to a ViewModel
    MainWindowViewModel indirectly adds
    and removes Workspace ViewModel
    objects to and from the main window’s
    Tab Control. By relying on data
    binding, the Content property of a
    TabItem receives a
    ViewModelBase-derived object to
    display. ViewModelBase is not a UI
    element, so it has no inherent support
    for rendering itself. By default, in
    WPF a non-visual object is rendered by
    displaying the results of a call to
    its ToString method in a TextBlock.
    That clearly is not what you need,
    unless your users have a burning
    desire to see the type name of our
    ViewModel classes! You can easily tell
    WPF how to render a ViewModel object
    by using typed DataTemplates. A typed
    DataTemplate does not have an x:Key
    value assigned to it, but it does have
    its DataType property set to an
    instance of the Type class. If WPF
    tries to render one of your ViewModel
    objects, it will check to see if the
    resource system has a typed
    DataTemplate in scope whose DataType
    is the same as (or a base class of)
    the type of your ViewModel object. If
    it finds one, it uses that template to
    render the ViewModel object referenced
    by the tab item’s Content property.
    The MainWindowResources.xaml file has
    a Resource Dictionary. That dictionary
    is added to the main window’s resource
    hierarchy, which means that the
    resources it contains are in the
    window’s resource scope. When a tab
    item’s content is set to a ViewModel
    object, a typed DataTemplate from this
    dictionary supplies a view (that is, a
    user control) to render it, as shown
    in Figure 10.

    The DataContext for the MainViewModel in App.xaml.cs serves as a starting point for our application.

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

Sidebar

Related Questions

I saw many threads with this tittle, but no one really speak about reuse
I have some singleton class (please, don't speak about singleton usage). class InputSystem :
I hope you can help me with a problem; first, please don't worry about
Not that I need it, but it was interesting to hear someone speak about
=== about me === I'm new to android development and barely able to speak
This is related to the question about return type attributes and anonymous classes ,
Recently I heard Kirk Pepperdine speak about changing garbage collectors for better performance --
Having read some postings here about this topic, I realize that there are quite
Maybe im probably all wrong about this. Here goes.. I have the: gestureScanner =
I don't speak very good English, not sure about title so will try to

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.