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

  • Home
  • SEARCH
  • 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 7063997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:46:49+00:00 2026-05-28T04:46:49+00:00

In my Silverlight MVVM application, in the code-behind of a view, I set the

  • 0

In my Silverlight MVVM application, in the code-behind of a view, I set the DataContext to a viewmodel as such:

this.DataContext = new MyViewModel();

However, I need to bind one control in the view to another in the same view. So, I need to set the DataContext of the control where I’m adding the binding to the view itself.

After browsing around, it seems like the definitive way of doing this in WPF is by adding:

DataContext="{Binding  
    RelativeSource={RelativeSource FindAncestor,  
    AncestorType={x:Type UserControl}}

to the control.

However the AncestorType property does not exist in Silverlight 4. Is there an equivalent, definitive line of code that is used for this scenario in Silverlight? I haven’t run into any website or answer that shows the best practice for this.

This may help me answer an earlier question where I am trying to bind a custom control and property within a view.

  • 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-28T04:46:50+00:00Added an answer on May 28, 2026 at 4:46 am

    Can you explain what do you want to do?

    Probably you can use ElementName from Binding class

    Here is a sample example from msdn page:

    <Border Margin="10" BorderBrush="Silver" BorderThickness="3" Padding="8">
      <DockPanel>
        <TextBlock>Choose a Color:</TextBlock>
        <ComboBox Name="myComboBox" SelectedIndex="0">
          <ComboBoxItem>Green</ComboBoxItem>
          <ComboBoxItem>Blue</ComboBoxItem>
          <ComboBoxItem>Red</ComboBoxItem>
        </ComboBox>
        <Canvas>
          <Canvas.Background>
            <Binding ElementName="myComboBox" Path="SelectedItem.Content"/>
          </Canvas.Background>
        </Canvas>
      </DockPanel>
    </Border>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using mvvm light to build a Silverlight application. Is there a code snippet
I'm creating a Silverlight 3.0 MVVM application using Silverlight.FX but my View is actually
I've got this Silverlight Prism application that is using MVVM. The model calls a
I am using the Business Silverlight application. I have incorporated some MVVM into this
I have a silverlight mvvm application that loads main view with 2 user controls
I have a silverlight application (MVVM) with a view that will be used by
We have application have been written in Silverlight using MVVM pattern. We need to
i am creating silverlight application and implementing MVVM pattern. in my view model i
On my MVVM silverlight application I have a dataDrid (in the View) and the
On my MVVM Silverlight application I need to call Domain service function to get

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.