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

The Archive Base Latest Questions

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

I have 2 nested DataContexts in following code ( DataContext and ItemsSource ): <TabItem

  • 0

I have 2 nested DataContexts in following code (DataContext and ItemsSource):

<TabItem Header="Something" Name="myTabItemName" d:DataContext="{Binding myViewModel}">
    <Grid>
        <DataGrid AutoGenerateColumns="False" ItemsSource="{Binding muObservableCollection}" Name="myDataGridName" HeadersVisibility="Column">
            <DataGrid.Columns>
                <DataGridTextColumn Header="Foo 01" Binding="{Binding Foo_01}" />
                <DataGridTextColumn Header="Foo 02" Binding="{Binding Foo_02}" />
                <DataGridTemplateColumn Header="My custom combobox">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <!-- Here I want to bind back to 'myViewModel's' myProperty. I've tried this way: -->
                            <ComboBox ItemsSource="{Binding Path=myProperty, RelativeSource={RelativeSource AncestorType={x:Type TabItem}}}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
            </DataGrid.Columns>
        </DataGrid>
    </Grid>
</TabItem>

I want to assign myViewModel (back) to ComboBox's DataContext. The problem is that ComboBox has ‘overwritten’ DataContext in line:

<DataGrid ItemsSource="{Binding muObservableCollection}" ... >

How can I do it?

  • 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:08:45+00:00Added an answer on June 14, 2026 at 5:08 am
    <ComboBox ItemsSource="{Binding Path=DataContext.myProperty, RelativeSource={RelativeSource AncestorType={x:Type TabItem}}}" />
    

    Should do the trick. However I would like to point out that what you want does not make sense: you bind your TabItem let’s say to a Order-instance, the DataGrid to its Orderlines, why do you want a combobox from the Order in the DataGrid? Al the columns will display the same value and if you change one row, the values for all rows change.

    I have run into this situation myself a couple of times that I needed access to an higher level (due to refactoring in combination with commands), but it is rather rare.

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

Sidebar

Related Questions

I have nested list of the following form: my_list = [['Some1', '2', '3.6', '4.5',
I have nested model as following Project model has_many keywords and keyword belongs_to project
I have a few places in my code where I have nested objects, but
I have nested xsl:for loops: <xsl:for-each select=/Root/A> <xsl:for-each select=/Root/B> <!-- Code --> </xsl:for> </xsl:for>
I have nested ObsevableCollections as seen below. For simplistic reason this is sample code
I have nested divs like this (pseudo code..) <div0> <div1></div1> <div2>fluid width</div2> <div3></div3> </div0>
I have nested iframes and I would like to use onload function for the
What if I have nested loops, and I want to break out of all
Is it possible to have nested set capabilities in this somewhat custom setup? Consider
I have a situation where I have nested toggle statements in jQuery. I have

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.