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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:53:04+00:00 2026-06-14T05:53:04+00:00

I use MVVM pattern so my own control contains View and ViewModel. ViewModel is

  • 0

I use MVVM pattern so my own control contains View and ViewModel.
ViewModel is connected with View by DataContext property. This makes problems with binding. Why?

Assume this situation:
I created new user control – for example – “SuperTextBox”. It have a property “SuperValue”.
And now I do something like that:

<Window>
    <Window.DataContext>
        <vm:WindowViewModel/>
    </Window.DataContext>

    <local:SuperTextBox SuperValue="{Binding Test}"/>
</Window>

I thought that “binding process” joins SuperTextBox.SuperValue with Window.DataContext.Test, but no, ‘binding process” joins SuperTextBox.SuperValue with SuperTextBox.DataContext.Test what is for me unnatural and misleading.

Other controls like “TextBox” I can use in above way because they do not have their DataContext.

How can I use MVVM pattern to creating UserControls keeping natural binding (to DataContext of parent control) ?

Edit:

I got many answers how binding to parent, but I know this earlier. The problem is – how can I create UserControl via MVVM patern (having ViewModel) and stay natural binding – default to parent DataContext.

I want to have ViewMoldel and still can binding like this:

<local:SuperTextBox SuperValue="{Binding Test}"/>

Is it possible?

  • 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-06-14T05:53:05+00:00Added an answer on June 14, 2026 at 5:53 am

    I feel oddly answering on my question but…
    In my own control i did something like that:

    <UserControl>
        <Grid>
            <Grid.DataContext>
                 <vm:UserControlViewModel />
            </Grid.DataContext>
            // here realy code of control
        </Grid>
    </UserControl>
    

    Now I can use “natural” binding outside of control and in control. 🙂

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

Sidebar

Related Questions

I am writing an app using the MVVM (Model-View-ViewModel) pattern and am leveraging the
I have a WPF view (I use MVVM pattern) with a datagrid and some
I am required to use the mvvm pattern. I know that the viewmodel should
I'm working on a WPF application and I'm using the MVVM pattern. I use
Can I use UnityContainer in View's codebehind when I want to write good MVVM
I'm writing an application in WPF using the MVVM-pattern and will really often use
I use MVVM pattern in my multithreading WPF app. Now in the model I
I use the MVVM-pattern in my WPF-application. Now I show a dialog with my
In my WPF application I use the MVVM pattern together with dependency injection. The
I began to use MVVM pattern yesterday.But for working with events i needed 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.